EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: rezzonico on February 17, 2014, 06:27:08 AM



Title: Ceck if datagrid exist
Post by: rezzonico on February 17, 2014, 06:27:08 AM
Hi all,

I have 2 tabs (tab1 and tab2)
In each tab I have a datagrid (datagrid1 and datagrid2)
The "save" button" is in the first tab and it saves the two datagrid.
If I click on tab2, then on tab1 and then on the "save" button, all is ok.
But if after I start the program I click on the save button the javascript stops at the following command

var rows = $('#datagrid2').datagrid('getChanges','inserted');

The reason is that datagrid2 do not exist.
How can I check if datagrid2 exists ?

Thanks in advance
Miche


Title: Re: Ceck if datagrid exist
Post by: stworthy on February 17, 2014, 05:51:02 PM
To detect if a datagrid is initialized, call .data('datagrid') please. If the undefined value returned, you need to create datagrid before calling any methods.
Code:
var dg = $('#datagrid2');
if (!dg.data('datagrid')){
  // no initialization
}


Title: Re: Ceck if datagrid exist
Post by: rezzonico on February 17, 2014, 11:51:52 PM
Hi stworthy

thanks a lot !

Miche