Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
90
Getting list of all expanded rows so that I can open them later
posted

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);
}

Parents
  • 17590
    Offline posted

    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.

    igHierarachicalgridExpandPreviouslyExpandedRows.zip
Reply Children