Filtering on DT_RowId

Filtering on DT_RowId

Peter SpegelPeter Spegel Posts: 1Questions: 1Answers: 0

Is it possible to filter on DT_RowId without creating an invisible column? I'm guessing I should create a function:

$.fn.dataTable.ext.search.push(
  function( settings, data, dataIndex ) {
    return DT.row(dataIndex).DT_RowId === theIdThatIWantToSearchFor;
  });

But I wasn't able to extract the DT_RowId from the DataTable row. Is this only possible by looking at the <tr> using jQuery?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin
    Answer ✓

    The answer is yes, but it is currently an undocumented feature (simply because I haven't got around to writing the documentation yet - apologies! It is near the top of my top do list now!).

    The data property that is passed in to the custom search function is an array of the data for filtering, however, 1.10.1+ now pass in a couple of other parameters:

    1. settings - The settings object
    2. data - The filter data, in an array, for the row
    3. dataIndex - The row's data index int he table
    4. origData - The row's original data object / array
    5. loopCnt - Loop counter for the current filter

    So using the new 4th parameter you can simply do origData.DT_RowId to access the property you want!

    Regards,
    Allan

This discussion has been closed.