How can i change cell value of cached table ?

How can i change cell value of cached table ?

MalindaMalinda Posts: 5Questions: 1Answers: 0

Hi, I'm using page cacheing as described in the piplining example in my table.

Now i need to reload one row when click on a table inside that row.

First i send a request to server to edit the record and if request is success i just changed cell value using table.cell( row, col).data("Accepted").invalidate();

But this is not working as i expected. New value, Accepted is immediately disappear after setting it. I think it happens because the caching. Is there any way i can update cached data ?

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin
    Answer ✓

    The *().data() methods are effectively useless if you are using server-side processing. When you are using server-side processing, DataTables is just a dumb display and event handler - the data is stored at the server side, and if you want to update it, you need to change the data at the server-side and then redraw the table. That is the trade-off of using server-side processing.

    If you are using pipelining and want fresh data, you need to remember to call clearPipeline() as well, since otherwise you'd just get the cached data.

    Allan

  • MalindaMalinda Posts: 5Questions: 1Answers: 0

    Thank you @allan,

    If i redraw table, will it redraw selected row or the whole table ?

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin
    Answer ✓

    With server-side processing enabled, the only option is to redraw the whole page (i.e. the DataTables page being show).

    Allan

  • MalindaMalinda Posts: 5Questions: 1Answers: 0

    Well i have around 1200 records to show. What do you suggest to load these all without conflict ?

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin
    Answer ✓

    With only 1200 records, I wouldn't use server-side processing. I'd only suggest you do that when you have at least tens of thousands of records.

    Allan

  • MalindaMalinda Posts: 5Questions: 1Answers: 0

    Ok. One last thing. If i have 1000000 records. Is there any way to load data with chunks ( first we get 1000 records and after that 1000, we get next 1000 like that) without caching ?

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin
    Answer ✓

    Server-side processing with a page length set to 1000 would do it.

    Allan

  • MalindaMalinda Posts: 5Questions: 1Answers: 0

    Ok thank you so much for you help

This discussion has been closed.