How to access attributes of td ?

How to access attributes of td ?

yannFrenchyannFrench Posts: 3Questions: 2Answers: 0

Hello,

Please excuse me, my English is not very good.

I have a datatable array with each row of this form :

<tr id="1234">
    <td id="td_mob_1234" colspan="2"> xxxxx </td>
    <td id="td_desk_1234" style="display: none;"> yyyy </td>
    <td>aaa</td>
    <td>bbb</td>
</tr>

At some point, I need to edit all the rows in the table.
- So I get the lines of the table.
- I'm making my changes.
- And I apply them that way.

var data = datatable.rows().data();

for (var i = 0, row; row = data[i]; i++) {

    // I'm making my changes. on row[0], row[1].....

    // apply
    datatable.row(i).data(row).draw();

}

My problem is that row [0], row [1]…. contain only the inside of my td.

I would also need to access the attributes of my td, to change from colspan = 2 to colspan = 1 and from display: none to display: block for the second td.

How can I access and modify these attributes?

Thank you

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    You can access it by use cell().node(), but one problem is that DataTables doesn't support colspan (or rowspan) within the table's body, only in the header.

    Colin

  • yannFrenchyannFrench Posts: 3Questions: 2Answers: 0

    Thank you Colin,
    I managed to do what I wanted.
    For the colspan with datatable, there is a trick which consists in having a td with style = "display: none;" so that the number of columns is correct.
    For me it works anyway.

Sign In or Register to comment.