Hi experts, please take a look at following link, http://www.igniteui.com/hierarchical-grid/overview . What's the best way to get the Beverages row, and then get "Fruit punch" row, and then get the quality of this row, which is 4. I know I can definitely do this by iterating the table dom tree, but is there a specific iggrid api for doing this?
If I try from outer grid to inner grid, I can get all rows of hierarchical grid by using http://help.infragistics.com/jQuery/2015.1/ui.iggrid_hg#methods:rows, but how can I get the inner grid widget of row[1]?
If I try from inner grid to outer grid, I can get all children widgets by using http://help.infragistics.com/jQuery/2015.1/ui.ighierarchicalgrid#methods:allChildrenWidgets, but how can I know which row this inner widget belongs to?
Hi Ming,
Another approach to get a specific value of the child grid is to use getCellValue API method on for example childCreated event:
$(document).delegate("#hierarchicalGrid", "igchildgridcreated", function (evt, ui) { var childGrid = ui.element; for(var i = 0; i < $(childGrid).igGrid("rows").length; i++){ var val=$(childGrid).igGrid("getCellValue", i, "Quantity"); console.log(val); } });
This above code will display in the console all expanded child rows values that belong to "Quantity" column, in case that the hierarchicalgrid children are loaded on demand. I'm attaching a sample for your reference. If you have further questions, please let me know.
Regards,
Tsanna
Hi Tsanna, thank you very much for your reply. Yes, I can always get the value via its underlying datasource. But the premise is that I always know the index of that row. Imagine I have a huge datasource, and I need to find out which product's quality equals 4, the only way comes to my mind is to loop through this huge datasource? Is there a more efficient way to do this? Can I get the row value at the time when each row get bounded/rendered, so I can save the time of loop through this huge datasrouce? Thanks in advance.
Hello Ming,
You can access the "Beverages" row data and its child row data using the following code:
$("#hierarchicalGrid").data("igHierarchicalGrid").options.dataSource[1].Products[1].Name - this will return "Fruit punch"
$("#hierarchicalGrid").data("igHierarchicalGrid").options.dataSource[1].Products[1].Quantity - this will return "4"
If you have any further questions, feel free to contact me.