This is a migrated thread and some comments may be shown as answers.

[Solved] JS Version of IsInEditMode?

4 Answers 195 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 26 May 2009, 07:50 PM
I need to know if my grid is in edit/insert mode from the client side. Can one of you guys tell me how I should approach this?

Thanks in advance!

4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 27 May 2009, 06:58 AM
Hello Michael,

Please test the following approach:
if(radGridClientObject._editIndexes.length > 0) 
    //edit mode 

Regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Tonino
Top achievements
Rank 1
answered on 02 Feb 2010, 04:07 PM
Hi Daniel
What would be the syntax to use for the 'classic' grid control?
Thanks,
Tonino.
0
Daniel
Telerik team
answered on 03 Feb 2010, 04:13 PM
Hello Tonino,

You can traverse the rows and check their ItemType:
var mtable = window["RadGrid1"].MasterTableView;
for(var rowNum = 0; rowNum < mtable.Rows; rowNum++)
{
    if(mtable.Rows[rowNum].ItemType.indexOf("Edit") != -1)
        //this item is in edit mode
}

Best regards,
Daniel
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Tonino
Top achievements
Rank 1
answered on 04 Feb 2010, 09:06 AM
Hi Daniel
Had to change mtable.Rows to mtable.Rows.length in the for-loop, but now it works for update. To detect inserts I check IsItemInserted.

Here the complete code:
function AlertIfEditOrInsertMode() { 
   var mtv = window["RadGrid1"].MasterTableView; 
   if (mtv.IsItemInserted) { 
      alert('Terminate insert/update first!'); 
      return true
   } 
   for (var rowNum = 0; rowNum < mtv.Rows.length; rowNum++) { 
      if (mtv.Rows[rowNum].ItemType.indexOf("Edit") != -1) { 
         alert('Terminate insert/update first!'); 
         return true
      } 
   } 
   return false


Thanks!

Tonino.


Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Tonino
Top achievements
Rank 1
Share this question
or