datatable reload data

I’ve a datatable with large data and dynamic loading. Some serverFilters in the table. Data comes by ajax json php script.

i want to refresh shown data every 60 seconds, because some other use could have changed entries. Or some may be new, some may be deleted.

whats the best way to do this?

You can call table.filterByAll() each 60 seconds, which will trigger serverFilter and will reload the table. Or just call the dtablt.load with last called url

Both methods have disadvantages. filterByAll - will break edit operation ( if editor was active during reloading ), load - will not break anything, but while it can add|update records in datatable it will not delete records that was removed by other user.

The best solution requires a more complicated backend - WebSockets, MeteorJs, FireBase, etc. - server side that can inform client about data changes instead of full data reloading.

i tried table.filterByAll() before posting this - but it does NOT refresh data

You are right
Try to use loadNext instead

http://webix.com/snippet/ca651985

works. thank you! :slight_smile:

but… when the server side data has been resorted (i.e. rank has changed) the existing data is shown in the old order using loadNext. any suggestion?

Yep, I can see the problem.

As temporary solution you can use

dtable.loadNext(-1,0,{
			before:function(){
				var url = this.data.url;
				this.clearAll();
				this.data.url = url;
			}
		},0,1);

It will clear old data before loading the new one

In next version (2.3) we will make serverFilter more similar to normal ones. So call to filterByAll will force data reloading in case of server side filters.

Thank you. What I found out that works in the meantime is

dtable.loadNext(-1,0, null, dtable.data.url);

hi Chris, Can you tell me how many seconds your datatable with large data and dynamic loading takes?
Thank you in advance.

@jonard_7777: server response immediately with some hundred records. its really fast. rest is loaded as needed.

Is there a better, current, solution to updating tables in realtime? (I saw the Websocket post but that’s from 2014).

This is especially interesting for GraphQL, which has realtime subscriptions.

WebSockets still the best solution

For GraphQL subscription to work, we will need to use WebSockets as a transport anyway.

Any progress on documenting WebSockets? The Interacting with the server side page still shows WebSockets as deprecated, but the 6.3 release mentions new widget samples. However, the sample doesn’t work (it attempts to use a localhost websocket).

Hi Dan,

still shows WebSockets as deprecated

Yep, we have deprecated the Faye proxy, but there won’t be any built-in solution for communicating with Web sockets in the library core. It is rather use-case specific and can easily be tuned with server proxies.

We have already published a blog tutorial describing one of the ways to set up Webix with Web Sockets:

https://blog.webix.com/websocket-real-time-data-updates-for-webix-widgets/

So the sample relates to this tutorial mainly. If you download the package and set up samples locally, it works fine (runnode backend/index.js). Still, we will update the online copy in the nearest time as well.