EasyUI Forum
May 21, 2024, 10:25:02 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Ceck if datagrid exist  (Read 6477 times)
rezzonico
Full Member
***
Posts: 184


View Profile
« 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
« Last Edit: February 17, 2014, 06:28:49 AM by rezzonico » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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
}
Logged
rezzonico
Full Member
***
Posts: 184


View Profile
« Reply #2 on: February 17, 2014, 11:51:52 PM »

Hi stworthy

thanks a lot !

Miche
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!