Datatable refresh with new data
Datatable refresh with new data
makif
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
This discussion has been closed.
Answers
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()
anddraw()
to add the new data to the table.Kevin
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.
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 thesuccess
function of the Ajax request userows.add()
anddraw()
to update the table.You will probably want to use`setTimeout to periodically run a function that performs the Ajax request.
Kevin