I need to be able to get a list of rows (client side) that have been expanded, so that when a user reloads the page, I can then expand them.
I've seen code to get the expanded rows, but trying to expand them again, doesn't seem to work. I'm missing something obvious I'm sure.
This is the code that I found (on the forum) to get all the expanded rows:
arrExpandedRows = $("#gridRRA").igHierarchicalGrid("allChildren");
This is what I was using to expand the rows (found in the forum):
for (i = 0; i < arrExpandedRows.length; i++){ var rowDom = $("#" + arrExpandedRows[i].id); $("#gridRRA").igHierarchicalGrid("expand",rowDom); }
Hello Mike,
Every row that is currently expanded has an area-expanded attribute that is set to true. In order to get all expanded rows at a certain point of time you can use a jQuery selector for all the rows that has this attribute value set to true. For example:
var expandedRows = $("#hierarchicalGrid tr[aria-expanded=true]");
expandRows will be a collection with all currently expanded row DOM elements.
Afterwards, when you want to expand them again you can use expand method of the igHierarachicalGrid. It takes row DOM element as an argument and it could be retrieved from expandRows collection. For example:
$("#btnExpandRows").click(function(){ if(expandedRows){ $.each(expandedRows, function(){ $("#hierarchicalGrid").igHierarchicalGrid("expand", this); }); } })
I am attaching a small sample illustrating my suggestion for your reference. First expand a row/rows and click "Get Expanded Rows button". Then collapse them and click the "Expand Previously Expanded Rows Button". All previously collapsed rows will be expanded again.
Please let me know if you need any further assistance with this matter.
This works great, as long as you haven't shut down the browser or rebound the grid even in the current session.
What I'm trying to achieve is to allow them to come back to the web page later and have the rows they were looking at expanded again.
$("#btnRebindData").click(function(){
expandedRows = $("#hierarchicalGrid").igHierarchicalGrid("dataBind");})