Hi,
I'm trying to use a search component to populate the hierarchical grid with json data. The issue I'm running into is that the grid is initialized on screen load and the datasource is set to a json object that is empty i.e "var datasource = [];" When I then get data via an ajax call and try to update the datasource object with the data returned from the ajax call and rebind my grid "$("#myHierarchicalGrid").igHierarchicalGrid("dataBind");" nothing happens.
Is there a way to initialize the hierarchical grid initially to an empty json object and rebind it with a json object at a later point in time? I also tried to do something like the following code snippet, but because the grid's initial datasource was empty it doesn't return any child table elements for me to bind to.
$('#hierarchicalGrid').igHierarchicalGrid('allChildrenWidgets')[0].dataSourceObject(jsonObject);
Any help would be greatly appreciated!!!
Hi, Chris.
Thank for using our product and contributing in our community.
You can change the data source after grid is initialized, using the dataSource option of the grid. Once you change it at runtime, you don't need to rebind, the grid does this internally. Please try the following code and tell me if it fits your case ("adventureWorks" is JSON data source).
$("#grid1").igGrid({
dataSource: [],
features: [ { name: "Paging", type: "local", pageSize: 13 } ]
});
$("#grid1").igGrid("option", "dataSource", adventureWorks);
For any further questions, please don't hesitate to ask me.
Best regards, Nikolay Alipiev
I want to ask you if you had the time to try my solution and I want to know if it is working for your case. If you have any further questions don't hesitate to ask me.
Hi, Chris or DHS Development.
I'm glad to hear that you resolved your issue. You can re-initialize the grid and this is one of the solutions. In other case setting the data source of the hierarchical grid should work also and it is similar to igGrid one:
$("#grid1").igHierarchicalGrid("option", "dataSource", adventureWorks);
If you want me to examine the case in that direction don't hesitate to ask me.
Best regards,
Nikolay Alipiev
Thank you for your solution and that one did help with the rebinding of the standard igGrid. However I still had issues with this in regards to the igHierarchicalGrid. What ended up working for me was just re-initializing the hierarchical grid each time I needed a new dataset bound to it.