Pagination and sDefaultContent

Pagination and sDefaultContent

almightyalmighty Posts: 8Questions: 0Answers: 0
edited May 2013 in DataTables 1.8
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.

Replies

  • allanallan Posts: 54,688Questions: 1Answers: 8,553 Site admin
    Use the fnGetNodes or $ method ( http://datatables.net/docs/DataTables/1.9.4/DataTable.html#$ ) to get nodes regardless of paging.

    Allan
  • almightyalmighty Posts: 8Questions: 0Answers: 0
    Thanks for the rely mate,

    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.
  • almightyalmighty Posts: 8Questions: 0Answers: 0
    i am using fnGetNodes to get all the nodes. I need all but one, the one that i don't need is with me, how to remove it from all nodes that i get from fnGetNodes.
  • allanallan Posts: 54,688Questions: 1Answers: 8,553 Site admin
    Use array splice perhaps? https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/splice

    Allan
  • almightyalmighty Posts: 8Questions: 0Answers: 0
    Thanks mate it worked.
    var positionOfCurrentRow = dataTable.fnGetPosition($(modifiedRow).get(0));
    totalRows.splice(positionOfCurrentRow, 1);
This discussion has been closed.