Update a whole single row v1.10+

Update a whole single row v1.10+

npsarrakosnpsarrakos Posts: 4Questions: 1Answers: 0

I have been trying a whole row by updating it's html directly.

It does but the problem is, I have made some columns invisible beforehand.

So when I get the new HTML for the row from the template, like I did initially, it has the all the TDs.

I tried doing datatable.row(index).invalidate().draw();
but it doesn't work :/

Any clue?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,300Questions: 26Answers: 4,945

    datatable.row(index).invalidate().draw();

    This should work but depends on what else you are doing. Can you provide a link to your page or an example?
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • npsarrakosnpsarrakos Posts: 4Questions: 1Answers: 0

    Here's an example:
    http://live.datatables.net/jumequzo/1/

    As you check on the second row it shows the whole tr without hiding the TDs as it should.

    In my page, I can't modify the data and then invalidate,draw. The reason I am using a template is because I am using various tpl stuff like classes in the TDs, plus the TDs have info about sorting like data-sort etc.

    Thanks in advance.

  • kthorngrenkthorngren Posts: 21,300Questions: 26Answers: 4,945

    Thanks for the example. I think you will be better off using Datatables API's to update the row. I updated your example to use row().remove() and row.add():
    http://live.datatables.net/yeyibaqa/1/edit

    In my example I find the row index then remove it. However there are many row-selectors you can use to select the row to delete. Then I add the HTML directly. Note you need to add using TR in tour string.

    Kevin

  • npsarrakosnpsarrakos Posts: 4Questions: 1Answers: 0

    It's a nice step thanks kthorngren.

    There's another problem though, this causes the table to redraw and lose it's current page.

    I have update the example to showcase this. Change page to a next one and then Click the button to check this.

    http://live.datatables.net/yeyibaqa/2/

    Thanks

  • kthorngrenkthorngren Posts: 21,300Questions: 26Answers: 4,945
    Answer ✓

    You can use .draw(false), as described in the draw() docs, to stay on the same page.

    Kevin

  • npsarrakosnpsarrakos Posts: 4Questions: 1Answers: 0

    True I was checking the documentation and tried it, and then came back and saw your comment.

    Thanks kthorngren :)

This discussion has been closed.