I use the following code to expand the row.
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:
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.
var expander = $(this).datagrid('getExpander', index);
if (expander.hasClass('datagrid-row-expand')){
$(this).datagrid('collapseRow',index);
}else{
$(this).datagrid('expandRow',index);
}