deleting JSon loaded data? (even just on the client)

deleting JSon loaded data? (even just on the client)

javahollicjavahollic Posts: 11Questions: 0Answers: 0
edited February 2010 in General
Hi,
I have a table loading dynamic Json data, great. Following the delete example, I can't figure out how to get the data in the browser to be deleted. The example seems to work fine for 'static' HTML, but there isn't one for dynamically loaded Json data. Is there something Im missing with that approach?

Here is the script bit:
[code]
function fnDeleteSelected( oTableLocal )
{
var aTrs = oTableLocal.fnGetNodes();
for ( var i=0 ; i

Replies

  • javahollicjavahollic Posts: 11Questions: 0Answers: 0
    I ought to say I've tried extracting the index: oTable.fnDeleteRow( oTable.fnGetPosition(aTrs[i]) );
    and also from an int value: oTable.fnDeleteRow(0); etc, but both seems to result in the same non deletion...
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I think I see the problem here - you've got server-side processing enabled... So if you aren't actually deleting the row from the database, and DataTables refreshes it's display (which is does on fnDeleteRow) then you are going to get that row coming back! So I think fnDeleteRow is actually doing the right thing - but you should see an XHR which is then refreshing the display!

    If you want to delete rows, and use server-side processing, you need to actually do the delete on the database - where all the information is kept.

    Regards,
    Allan
  • javahollicjavahollic Posts: 11Questions: 0Answers: 0
    Hi allan,
    OK I get you, so in the delete.click, I do ajax to the server to trigger deletion of the index selected (um I hope that keeps working with paging?) then call fnDeleteRow to get the byproduct of a full refresh?

    thanks,
    andy
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi Andy,

    What you need to do is:

    1. Send an XHR to delete the row from the database
    2. Call fnDraw() on the table to 'refresh' the display (with the deleted row now gone!)

    There is no need to call fnDeleteRow at all when using server-side processing, it doesn't provide any use. The pagination is automatically taken care of since DataTables will just redraw the data without the row from the server now.

    Regards,
    Allan
This discussion has been closed.