Display new created rows on top

Display new created rows on top

mc2devmc2dev Posts: 33Questions: 6Answers: 0

Hello,
I'm looking for a simple way to display each new created row on top of table.
I create my new rows inline.

I need something close to this example : https://codepen.io/quanghuy1294/pen/OgNELB
But when I try it, it works but creates few problems with my datatable structure : After create a new row, edit the last one, update the first one too... I'm using an inline edit too.

If you know a simpler way to handle this, thank you to share it!

Answers

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

    You could try adding a hidden column, one that's not shown in the table or the Editor form, which you then use alongside the Absolute sorting plugin. This example from this thread is demonstrating its use.

    Colin

  • mc2devmc2dev Posts: 33Questions: 6Answers: 0

    Thank you for your answer Colin.
    But I already use "targets" option to hide dynamically some columns on the first display.
    Is there an other solution which match my need?
    Thanks again for your help!

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

    Your issue is that the table would be sorted, so you need something like the Absolute plugin, or some hidden field that you order by, to force that column to the top - otherwise the standard ordering would kick in and move the record to where the ordering determines it belongs.

    Colin

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    Another option is to use a plugin to jump to the page containing the new or updated row. Take a look at these:
    https://datatables.net/plug-ins/api/page.jumpToData()
    https://datatables.net/plug-ins/api/row().show()

    Kevin

Sign In or Register to comment.