Row ids not set when using idSrc?

Row ids not set when using idSrc?

EtheloEthelo Posts: 3Questions: 2Answers: 0

In the simple example (https://editor.datatables.net/examples/simple/simple.html) every row has a unique id

<tr id="row_28" role="row" class="odd"><td class="sorting_1">Brenden Wagner</td><td>Software Engineer</td><td>San Francisco</td><td>1314</td><td>2011-06-07</td><td>$206,850</td></tr>

However, in the id source example (https://editor.datatables.net/examples/advanced/jsonId) there are no ids

<tr role="row" class="odd"><td class="sorting_1">Brenden Wagner</td><td>Software Engineer</td><td>San Francisco</td><td>1314</td><td>2011-06-07</td><td>$206,850</td></tr>

Do ids need to be added manually when using idSrc or am I missing an option to turn these on?

Thank you

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 4,694Questions: 0Answers: 823
    edited February 14

    Hi @Ethelo ,

    In both examples, the ID is being sent with the Ajax data for each row. In the first, it uses the default ID name, DT_RowId. The second example is there because it's using a different column name, just id, so Editor needs to be told to use that instead. There's more explanation on this page - idSrc.

    Hope that makes sense,

    Cheers,

    Colin

  • EtheloEthelo Posts: 3Questions: 2Answers: 0
    edited February 19

    The id is being used properly in the column, but it does not appear in the tr class itself when idSrc is being used.

    I wanted to know if I have to add an id attribute to the <TR> element manually when using idSrc. Many of the tutorials and examples assume there is an id attribute.

  • kthorngrenkthorngren Posts: 5,544Questions: 19Answers: 1,233
    Answer ✓

    You would use the Datatables option rowId to set the tr element.

    Kevin

Sign In or Register to comment.