The following script retrieves reference to the first child of first row in grid.
var firstChildGrid = $('#grid1').igHierarchicalGrid('allChildrenWidgets')[0]; firstChildGrid.dataBind();
what I need is to go down one more level and then dataBind.
Thanks
-Chuck
Hello,
I am currently working into this and will provide a sample for the option 2 scenario. Thank you for your patience and understanding.
Hello Hristo
If oyu could supply example for option 2, that would be most appreciated.
Hello Charles,
Thank you for the snippet shared. At the time CheckStatus is called second level grids' widgets are not initialized yet, this is why firstChildGrid.childrenWidgets() returns undefined. To go around this you can:
1) set the initialExpandDepth property to 1 so that the second level grid's are initialized and calling firstChildGrid.dataBind() will create and render the second level grid's also.
2) get reference to the second level grids' widgets on rowExpanding event and then call secondLevelGrid.dataBind()
Since I am not into the details of your scenario I cannot say which would be better. Please let me know which one do you prefer and if you need assistance on how to do it I could be able to prepare a small sample for you.
Looking forward to hearing from you.
Hopefully this expample explains what I'm tryin to do. I have grid this lists Customers and their orders. For each order there is an action to check status. When clicked I want to rebind the Customer row the order appears. This example is a simplification of the scenario. here is example grid definition and Javscript for refreshing the grid.
(Html.Infragistics().Grid(Model.CustomerProfiles.AsQueryable()).ID("ProfilesList").Width("100%").LoadOnDemand(true).AutoGenerateColumns(false).AutoGenerateLayouts(false).PrimaryKey("ProfileSeq").Columns(col =>{ col.For(x => x.Name).HeaderText("Name").Width("45%");}) .ColumnLayouts(layouts => { layouts.For(x => x.OrderList) .PrimaryKey("ProfileSeq") .DataSourceUrl(Url.Action("GetMembersList")) .Width("100%") .Columns(childcolumn => { childcolumn.For(x => x.OrderNumber).HeaderText("Order Number"); childcolumn.For(x => x.status).eaderText("status"); childcolumn.For(x => x.actions).HeaderText("Allowable Actions") .Template("<a href='#' onclick='CheckStatus({ProfileSeq})>Check Status</a>"); });}).Features(feature =>{ feature.Sorting().Type(OpType.Local); feature.Paging().PageSize(10); feature.Filtering().Type(OpType.Local);}).DataBind().Render())
}
<script>
function CheckStatus(seq){ var findValue = 'tr[data-id="{0}"]'.replace("{0}", seq); var $element = $('#ProfilesList').find(findValue); var idx = $element.attr('data-row-idx');
var firstChildGrid = $(grid).igHierarchicalGrid('allChildrenWidgets')[idx]; firstChildGrid.dataBind();}
</script>
The allChildrenWidgets method will return an array with all child grid's widgets regardless of their level in the hierarchy. This means [2] could return you a child grid that is bound to the first row of the grid ass in the following example. At the right of every row I have put the subscript that rill return reference to the corresponding child grid widget:
It is also possible that at different time not all widgets are initialized, so it would be better to check the level of the grid to get reference to the one you need.
If you share more details about your scenario (at what time you try to databind and if you need to do it for every grid in the hierarchy) I will be glad to provide a suggestion how this could be done.
Looking forward to your answer.