EasyUI Forum
April 28, 2024, 06:42:24 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Ondoubleclickrow expand and collapse row  (Read 4687 times)
Alfred
Full Member
***
Posts: 134


-Licensed User-


View Profile
« 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);
                    }
Logged
Alfred
Full Member
***
Posts: 134


-Licensed User-


View Profile
« Reply #1 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);
                    }
            }
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!