Is row.add() capable of adding row below the cell it is called?

Is row.add() capable of adding row below the cell it is called?

qwertymotaqwertymota Posts: 3Questions: 1Answers: 0

for example i have 4 rows on a table.. then when i click add on the 2nd row.. i want the newly added row to the 3rd row. and the others cells will move down..is this possible in datatables?

Answers

  • anaganag Posts: 48Questions: 2Answers: 7
    edited June 2014

    If you have a button or link within a cell in a row which is adding a row when clicked similar to the demo at http://datatables.net/examples/api/add_row.html

    You should be able to modify the add.row function to use jQuery insertAfter or after function. Maybe using this in jQuery, or traverse up the dom to get the first tr and insert after.

  • qwertymotaqwertymota Posts: 3Questions: 1Answers: 0
    edited June 2014

    the link is broken dude.

    and :

    im using newRow.insertAfter($(this).closest("tr"));

    it will add rows in my table but it doesnt affect the row count in datatables.. how to re- draw(); the table for the pagination to be applied to the updated table with new row

  • qwertymotaqwertymota Posts: 3Questions: 1Answers: 0

    BUMP!.

    really need this

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin

    The link just needs the . at the end to be removed to make it correct.

    im using newRow.insertAfter($(this).closest("tr"));

    Won't work, as explained in the FAQs.

    The short answer is no - row ordering in the table is applied only by the ordering rules that are applied to the table. So if you want a row to appear in a particular position, the data in the table, when sorted, needs to put that row into that position. You can apply a custom sort to achieve that if required. See this example for how to write a plug-in sorting function.

    Allan

This discussion has been closed.