EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Juan Antonio Martínez on February 02, 2015, 05:53:09 AM



Title: Datagrid: fire onLoadSuccess just once
Post by: Juan Antonio Martínez on February 02, 2015, 05:53:09 AM
Hi all
Any easy way to fire datagrid onLoadSuccess just once?

Something like:
Code:
function loadAndFire() {
$('#my-datagrid').datagrid(
        'load',
        {
         Prueba: workingData.prueba,
         Jornada: workingData.jornada ,
         Manga: workingData.manga ,
         Operation: 'getData'
        }
).done(function(data) {myFiredFunction(data);} );
}

Thanks in advance
Juan Antonio


Title: Re: Datagrid: fire onLoadSuccess just once
Post by: stworthy on February 02, 2015, 06:47:18 PM
You must define 'onLoadSuccess' event in the datagrid component before using it.
Code:
$('#my-datagrid').datagrid({
onLoadSuccess:function(data){
//...
}
});
$('#my-datagrid').datagrid(
    'load',
    {
    Prueba: workingData.prueba,
    Jornada: workingData.jornada ,
    Manga: workingData.manga ,
    Operation: 'getData'
    }
);


Title: Re: Datagrid: fire onLoadSuccess just once
Post by: Juan Antonio Martínez on February 03, 2015, 09:22:02 AM
Sorry, perhaps my question was a bit malformed:

my code is something like:

Code:
function one() {
   ....
   $(dg).datagrid('load',data1);
   return;
}
function two() {
   ....
   $(dg).datagrid('load',data2);
   /* something to do AFTER load success */
   ....
}
function three() {
   ....
   $(dg).datagrid('load',data3);
   return;
}

I want to be able to call onLoadSuccess(), but only on function two(). Due to async nature of ajax call in 'load', I cannot simply add required code bellow

So I'm looking for:
- A way to enable/disable onLoadSuccess at an specific point, without affecting others
Or
- Add a sort of method like datagrid('load').done()

Juan Antonio