Hi Team,
I have created a hierarchical grid with 3 levels of data. I want to get the selected rows(Check box as row selector) data of third level on button click which is existing at second level.
I have tried below SelectedRows but getting error.
var childGrids = $("#hierarchicalGrid1").igHierarchicalGrid("allChildren");if ($("#hierarchicalgrid1").data("iggrid") != null) { var rows = $("#hierarchicalgrid1").iggridselection("selectedRows"); //do something
}$.each(childgrids, function (ix, grid) { var rows = $(grid).iggridselection("selectedRows"); $.each(rows, function (ix, row) { // getting the child grid selected row cell data rowid = row.element.attr("data-id"); var cellvalue = $(grid).iggrid("getcellvalue", parseint(rowid), "firstname"); console.log("child cell:" + cellvalue); // getting the parent grid row data var parentrow = $(grid).parents("tr[data-container='true']").prev("tr"); var parentrowid = $(parentrow).attr("data-id"); var parentrowgrid = $(parentrow).closest("table"); var parentcellvalue = $(parentrowgrid).iggrid("getcellvalue", parseint(parentrowid), "name"); console.log("parent cell:" + parentcellvalue); });});
Below is the error details.
Cannot Call methods on igGridSelection prior to Hierarchical grid Initialization; Attempted to call 'selectedRows'
Is it possible to get the selected rows data from second level? If so please explain me with a sample.
Thank You!!
Hi Chandana Tayi,
Thank you for posting in our forums!
The code you provided will traverse up the DOM and get the parent row information along with the currently selected child rows. Since the igHierarchcialGrid can only have selected rows in one child grid at a time, using your code should give you the desired results unless I am misunderstanding your requirements.
I have modified your code mostly to account for some capitalization issues. Please check out my jsFiddle here. Clicking on the button will output the selected child rows in the console.
If you have any further questions or concerns with this, please let me know.