How to select a row using the value set by idSrc : 'id'

How to select a row using the value set by idSrc : 'id'

DanielpDanielp Posts: 7Questions: 3Answers: 0

Hello,

I have looked and Googled but I can't find any examples of how to select a row using the value set by idSrc : 'id'.

Our MySQL table uses an auto-increment and index column named 'id'. I use the " idSrc : 'id' " to tell DataTables to use that column as the unique row identifier when communicating this our MySQL table.

I can retrieve the value set by idSrc : 'id' for that row by doing something like " table_data.row(index_value).data().id; "

However, I can't find a way to find a way to select the row based on the value present in the MySQL 'id' column.

Please help...

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Hi,

    idSrc is an Editor property, so it won't really help with the DataTables aspect of selecting the row. What you want in this case is to tell DataTables itself what property the row id is available in, which can be done with the rowId option (I know this might seem a little overboard in terms of configuration options - the Editor option was introduced before the DataTables' one, which is why both exist! - legacy...!).

    Then you would use an id selector for the row selector:

    table_data.row( '#myRowId' )...;
    

    Regards,
    Allan

This discussion has been closed.