EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Alfred on March 30, 2017, 01:34:20 AM



Title: Ondoubleclickrow expand and collapse row
Post by: Alfred on March 30, 2017, 01:34:20 AM
I use the following code to expand the row.

   
Code:
onDblClickRow:function(index,row){
                $(this).datagrid('expandRow',index);               
            }

I want to add collapseRow methods if the row is expanded. How do we know whether the row is expanded and add the collapseRow method in it? My attempt looks like below code:

Code:
onDblClickRow:function(index,row){
                if($(this).datagrid('expanded', index)){//if the row is expanded, call collapseRow method on doubleclick
                    $(this).datagrid('collapseRow',index);
                }else{
                     $(this).datagrid('expandRow',index);
                  }               
            }

How do we know which row expands? I am also trying the following code but it is not working, and there is no error as well.

Code:
var expander = $(this).datagrid('getExpander', index);
                    if (expander.hasClass('datagrid-row-expand')){
                        $(this).datagrid('collapseRow',index);
                    }else{
                        $(this).datagrid('expandRow',index);
                    }


Title: Re: Ondoubleclickrow expand and collapse row
Post by: Alfred on March 30, 2017, 01:57:24 AM
I just solved it using the following code:

Code:
onDblClickRow:function(index,row){
                    var expander = $(this).datagrid('getExpander', index);
                    if (expander.hasClass('datagrid-row-expand')){
                        $(this).datagrid('expandRow',index);                       
                    }else{
                        $(this).datagrid('collapseRow',index);
                    }
            }