EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: aswzen on September 22, 2014, 02:29:12 AM



Title: How to make the datagrid not automatic load data from the url that i assigned?
Post by: aswzen on September 22, 2014, 02:29:12 AM
How to make the datagrid not load data from the url that i assigned?  ???
because every i assign an url to datagrid, it will automatic load the data...

Quote
nb :
1. i don't want passing empty data to datagrid using .datagrid('loadData', {"total":0,"rows":[]})  in onLoadSuccess
2. i don't want to delete the data row by row like using .datagrid('deleteRow',{}) in onLoadSuccess
3. i don't want to assign the url in outline..or separated from the datagrid itself


i am sorry if i am missing something on documentation maybe...or it just my mistake..and
thanks in advance


Title: Re: How to make the datagrid not automatic load data from the url that i assigned?
Post by: stworthy on September 22, 2014, 04:07:14 AM
You can determine if to load the remote data by using the 'onBeforeLoad' event.
Code:
$('#dg').datagrid({
autoLoad:false,
onBeforeLoad:function(){
var opts = $(this).datagrid('options');
return opts.autoLoad;
}
});

If you want to load remote data, set the 'autoLoad' property to true and call 'reload' again.
Code:
$('#dg').datagrid('options').autoLoad = true;
$('#dg').datagrid('reload');