Datatable refresh with new data

Datatable refresh with new data

makifmakif Posts: 2Questions: 1Answers: 0

i am using fnStandingRedraw function but this function can draw all table and it does not control there is new data or not.
i want to control new data, if there is no new data, i shouldnot be refresh and if there is datas, just draw data not refresh all table
how can i do this, can you help me?
thank you

Answers

  • kthorngrenkthorngren Posts: 21,470Questions: 26Answers: 4,977

    You haven't provided much info to go on but I would use an ajax request to fetch new data from the server. Then use rows.add() and draw() to add the new data to the table.

    Kevin

  • makifmakif Posts: 2Questions: 1Answers: 0

    kevin thanks for your reply
    i can explain, i am using datatable 1.10.2 and also i use codeigniter if you need this information, so i request ajax and fill table, i use fnStandingRedraw function for refreshing table but this function refresh all talbe, it's not situation that i want. first i want to control database table has new row or not, if table has new rows , it will add the table.

  • kthorngrenkthorngren Posts: 21,470Questions: 26Answers: 4,977

    I'm not familiar with Codeigniter so can't give the specific steps. The first thing to do is to define how to know if there is new data, a timestamp or sequence number field for example. Then use jQuery Ajax to fetch the new data using the data option to send the latest timestamp or sequence in the client. The server can then query for anything after the timestamp and return that data. In the success function of the Ajax request use rows.add() and draw() to update the table.

    You will probably want to use`setTimeout to periodically run a function that performs the Ajax request.

    Kevin

This discussion has been closed.