Add new row, but not as last one

Add new row, but not as last one

idotzangidotzang Posts: 2Questions: 0Answers: 0
edited June 2009 in General
Hi,
I need to be able to add rows in a n arbitrary position in the grid.
fnAddData doesn't seem to support that.

One solution that comes to mind is to add using fnAddData, and then count on resorting to order the elements in the way that I want, but this seems awkward.

Is there a more elegant way to do this ?

10x,
Ido

Replies

  • allanallan Posts: 61,695Questions: 1Answers: 10,102 Site admin
    Hi Ido,

    Positioning in DataTables in determined solely by sorting (it is possible to override this by disabling sorting and manipulating the aiDisplay and aiDisplayMaster internal elements as you required) - which is the reason that fnAddData() doesn't allow the new row to go into a particular position, because it doesn't mean anything to DataTables.

    What can be done to achieve this effect though, is to have a hidden column which will be sorted upon (aaSortingFixed can be used to force sorting to always happen on a particular column first) and the index/position would be in that column.

    Hope that helps,
    Allan
This discussion has been closed.