Option rowId = function() ?

Option rowId = function() ?

dnagirldnagirl Posts: 36Questions: 2Answers: 0

I'd like to generate row ids by concatenating the value of the table id with the value in the pk column. If I set rowId = 'pk', the row ids use the pk value which gives me a numeric id. This means I cannot guarantee that those ids will be unique if I have more than one table on the page. It also breaks html4 specification for the id attribute (which I sadly have to comply with).

My problem is that if I set rowId = function(), I don't know what arguments that function would receive if any. Advice?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,815Questions: 1Answers: 10,517 Site admin
    Answer ✓

    It will be similar to columns.data as a function, but in this case only the first argument is actually useful, that is the the data source object / array for the row. So you could do something like:

    rowId: function ( row ) {
      return 'row_'+row.pk;
    }
    

    Allan

This discussion has been closed.