4

I have read many posts that talks about this but still I cannot find a clear answer to my question

I need to reload only 1 row when I click on a button

At the moment, I send an ajax request to the server that change a boolean value. The request change the db field but not the table obviously. Now I need to refresh the corresponding table field which is row specific.

$('#table').DataTable().ajax.reload();

This works but it is not quick enough

How can I refresh only the row where the modification happens. Even better if I can refresh only the specific field within the row

Something like this:

$('#table').DataTable().row(rowNumber).data();

I have read that I need to send an ajax request that give me the updated value and put it in the field. I know already what to put but how can I refresh the specific field?

Can you please show me an example

I am using dandelion datatables 1.1.0

QGA
  • 3,114
  • 7
  • 39
  • 62
  • I don't really think this is possible (ajax-reloading the table filtering by the row id was my first thought, but that would leave the table with only that one row), but I hope I'm wrong, this would be very useful. – Sebastianb Jun 09 '16 at 12:04
  • You can draw only one row with the code: `table.row(this).data( d ).draw();` try and comment your result – CMedina Jun 09 '16 at 15:59
  • @CMedina Unfortunately, redrawing the row wouldn't reload the data from the server. – Sebastianb Jun 09 '16 at 20:35
  • When you say: I need to reload only 1 row when I click on a button, you send data to ajax and what is your response?? – CMedina Jun 09 '16 at 20:47
  • I need to send an ajax request to the server that check if the data of that specific row has been changed. If yes then I need to redraw again only that row. I supposed that Datatable api has got already some methods that can help me with this. – QGA Jun 09 '16 at 21:29
  • 1
    I think the best you could do is make the ajax call that updated the field return the new values of the row, and manually change it and redraw in datatables. Datatables can reload itself using ajax, but it will do it as a whole, not just a specific row. – Sebastianb Jun 10 '16 at 20:20
  • any updates on this question? – Just a coder Nov 23 '19 at 17:53

0 Answers0