EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: aswzen on March 23, 2015, 07:57:12 PM



Title: Looping reload in collapsible datagrid (bug?)
Post by: aswzen on March 23, 2015, 07:57:12 PM
I have some problem here,

I want to make the datagrid collapsed if the datagrid rows is not empty..i can achieve it manually with this code below

Code:
$('#dg').datagrid({collapsed:true});

now i want to make it automatic collapsed, i try to put it on onLoadSuccess listener in datagrid so like the code below

Code:
onLoadSuccess:function(data){
if(data.total != 0){
$(this).datagrid({collapsed:true});
}
}

but what happen next is disaster, the page / datagrid always reload everytime and never stopped and then the browser crash

already tried to use
Code:
		$(this).datagrid('collapse');
$(this).panel('collapse');
but have no result

here the fiddle, change the if(data.total == 0){ to if(data.total != 0){ and press RUN button in top left . be carefull this will crash your browser
http://jsfiddle.net/aswzen/bgy4kg2k/3/ (http://jsfiddle.net/aswzen/bgy4kg2k/3/)

any suggestion ?

thanks in advance


Title: Re: Looping reload in collapsible datagrid (bug?)
Post by: jarry on March 24, 2015, 12:27:53 AM
The datagrid has not 'collapse' method. You have to call 'getPanel' method to get the panel object before calling this method. Please use the code below instead.
Code:
onLoadSuccess:function(data){
if(data.total != 0){
$(this).datagrid('getPanel').panel('collapse');
}
}