Hi !
I'm trying to implement live data on the client side with igGrid + igDataSource. I have html page and wcf rest service, i'am using setInterval method to request items from service.
setInterval(function () { $.ajax({ type: "GET", async: true, url: 'Service1/Orders', dataType: "json", success: function (result) { $(result).each(function (key, value) {
gridrowIndex++; gridDataSource.addRow(gridrowIndex, value, true); }); gridDataSource.commit(); }, error: function (xhr) { alert(xhr.responseText); } }); }, 5000);
All rows are coming to datasource, but there is no updates in my igGrid until i apply sort, group by, move to the next page by mouse click.
DataSource init:
var gridData = [];var gridrowIndex = -1;var gridDataSource = new $.ig.DataSource({ dataSource: gridData, type: "json", filtering: { type: "local" }, sorting: { type: "local" }, paging: { enabled: true, pageSize: 10, type: "local" } });
igGrid init:
$("#grid1").igGrid({ virtualization: false, autoGenerateColumns: true, autoCommit: true, dataSource: gridDataSource, height: '930px', width: '700px',
.....
});
I tried to play around commit(), savechanges() etc on igGrid and igDatasouce but it doesn't help.
What's wrong? any ideas?
I've found the solution by pushing items to gridData and calling .dataBind() on gridDataSource.
But my sorting options are canceled after this code execution.
How to save grid features state and add items?
https://www.igniteui.com/help/iggridHello Artem,
Thank you for your interest in igGrid.
I am glad that you have found solution for your original issue.
Regarding the sorting options I suggest you 2 solutions:
1) You can define the columnSettings of the desired columns and set defaultSortLocation https://www.igniteui.com/grid/sorting-local
https://www.igniteui.com/help/iggrid-sorting
Then after rebind your data will be sorted.
Using the columnSettings is the easiet way to "save" the "features state"
2) You can use dataBound event for the purpose
https://www.igniteui.com/help/iggrid
Inside the handler you should invoke the API methods of the features which you have enabled
www.igniteui.com/.../igtreegrid-features-overview
Let me know if you need further assistance