Row ids not set when using idSrc?

Row ids not set when using idSrc?

EtheloEthelo Posts: 4Questions: 3Answers: 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: 15,118Questions: 1Answers: 2,583
    edited February 2019

    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: 4Questions: 3Answers: 0
    edited February 2019

    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: 20,144Questions: 26Answers: 4,736
    Answer ✓

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

    Kevin

This discussion has been closed.