server side data table, how to add new row without calling the server
server side data table, how to add new row without calling the server
lucioanneoalex@gmail.com
Posts: 7Questions: 3Answers: 0
Hello, my data table is server side populated, anyway I need to add manually a new row without calling the server, but it seems that if I use the row.add api with the right clinet data a call to the server is done anyway. Is there a way to switch from server side mode to client side mode and vice versa ?
thanks for any help
This question has an accepted answers - jump to answer
Answers
When server side processing is enabled client side methods like
row.add()
aren't active. All processing is expected to be performed by the server. There is not a way to dynamically switch between client side and server side.If you don't want to push the row to the server you could use Javascript or jQuery methods to add the row directly to the HTML table. Datatables won't know about this and any
draw()
action like paging, sorting, searching will likely remove the row. You would then need to re-add the row if you expect it to remain. Thedraw
event could be used for this.Kevin
ok, thanks Kevin. Actually, I have two data sources: signalr (web socket) and the DB with the same jdata structure. At present I am using only the DB through a timer that fires the data table server ajax call each 60 secs. Now I would like to use signalr as the primary source of data to get the same data in realtime, but I want to maintain also the polling on the db as a backup (i.e. every 5 mins) just in case signalr misses an event or is not available. Maybe all I have to do is switch to client side and manage manually both the signalr real time data and the call to the web api to query the DB every 5 mins, and in both cases feed manually the data table.
Agreed - unless you have a large amount of data (tens of thousands of rows) then working with a socket for real time updates you'd really want to use client-side processing. Server-side processing will work, but you need to transport 10 rows (or whatever the page size is), because of how DataTables works in that mode, as Kevin says.
Allan