EasyUI Forum

General Category => General Discussion => Topic started by: ahybits on January 25, 2016, 05:57:42 AM



Title: EasyUI and Socket.IO
Post by: ahybits on January 25, 2016, 05:57:42 AM
HI,

I was wondering if I can get some ideas on how to accomplish the following:

I have a grid with 5 columns and around 30 rows.  I need the last column to be real time.  As a workaround, i have been using setInterval, but that loads the whole data (of course I can create another function to get just the data for the last column and update each row, but was hoping to find a way to use Socket.IO instead

How can i leverage realtime data with the datagrid?


Title: Re: EasyUI and Socket.IO
Post by: stworthy on January 25, 2016, 08:23:12 PM
You can call 'updateRow' method to update datagrid rows when receiving the data from the server.
Code:
socket.on('customevent', function(data){
// parse data;
$('#dg').datagrid('updateRow', {
...
})
})


Title: Re: EasyUI and Socket.IO
Post by: ahybits on January 26, 2016, 12:43:22 PM
Do you think I should still use the url: parameter for the datagrid to get the initial data and then jsut run the socket.on for updaterow
or
load all data via socket and then run updateRow as needed ?