Pagination and sDefaultContent
Pagination and sDefaultContent
almighty
Posts: 8Questions: 0Answers: 0
Hi,
I have got bunch of data from server side which i am showing using amazing datatables library. Each row is supposed to have edit and delete button that doesn't come from server.This i am setting in aoColumns as mentioned below
[code]
{ "mDataProp": null, "sDefaultContent": '' }
[/code]
Now the user can add a new row at that time i have to override this default value to provide save and cancel functionality for the same
[code]
var newNode = $('#expiryRulesDataTable').dataTable().fnSettings().aoData[whichRow].nTr;
[/code]
i get the node being added and then setting the html for the default column to required html. This also works fine.
The problem occurs when the user while adding the rows goes beyond the current page to next or latter pages which are not visible. This doesn't works and shows the default content again.
Any help would be appreciated.
I have got bunch of data from server side which i am showing using amazing datatables library. Each row is supposed to have edit and delete button that doesn't come from server.This i am setting in aoColumns as mentioned below
[code]
{ "mDataProp": null, "sDefaultContent": '' }
[/code]
Now the user can add a new row at that time i have to override this default value to provide save and cancel functionality for the same
[code]
var newNode = $('#expiryRulesDataTable').dataTable().fnSettings().aoData[whichRow].nTr;
[/code]
i get the node being added and then setting the html for the default column to required html. This also works fine.
The problem occurs when the user while adding the rows goes beyond the current page to next or latter pages which are not visible. This doesn't works and shows the default content again.
Any help would be appreciated.
This discussion has been closed.
Replies
Allan
well i had a look at my js again and figured out that while adding the row, in order to get to the newly added row i am traversing through the tbody tr, so when the added row lands up on the next page it wont be available in the html.
using dataTable().fnGetData().length to get no of rows and then ataTable().fnSettings().aoData[index].nTr
solved the problem.
Allan
var positionOfCurrentRow = dataTable.fnGetPosition($(modifiedRow).get(0));
totalRows.splice(positionOfCurrentRow, 1);