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

Grid state on the client side

4 Answers 98 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Uday
Top achievements
Rank 1
Uday asked on 24 Apr 2012, 12:17 PM
Hi,

I have button outside the grid, clicking on the button will add a new row to the grid. I also have edit template also. Is there a way at the client side I can find out if the grid is in edit mode or insert mode....

I am using the below statment to insert a new row in the grid..
 rgHotels.MasterTableView.InsertItem(); 

4 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 24 Apr 2012, 01:42 PM
Hello Uday,

Please check below code snippet.
var RadGrid1 = $find("<%=RadGrid1.ClientID %>");
 
               if (RadGrid1.get_editItems().length > 0) {
                // your grid is in edit mode
               }
               if (RadGrid1.get_masterTableView().get_isItemInserted() == true) {
                   // Your grid is in insert mode
               }


Thanks,
Jayesh Goyani
0
Uday
Top achievements
Rank 1
answered on 24 Apr 2012, 03:21 PM
Hi Jayesh,

Thanks for the code snippet

if (RadGrid1.get_editItems().length > 0)
It says get_editItems() is undefined. I also tried the below way. Even that throws the same error.
var grid = $find('MainContentPlaceHolder_rgHotels');                 
if (grid.get_masterTableView().get_editItems())

Other code for finding the insert is working fine. Could you tell what is the wayaround.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 25 Apr 2012, 07:16 AM
Hello Uday,

Please check below link.
http://www.telerik.com/help/aspnet-ajax/grid-gridtableview-get-edititems.html

Let me know if any concern.



Thanks,
Jayesh Goyani
0
Jayesh Goyani
Top achievements
Rank 2
answered on 25 Apr 2012, 07:21 AM
Hello Uday,

Please check below code snippet.
var grid = $find("<%=RadGrid1.ClientID %>");
               if (grid) {
 
                   var MasterTable = grid.get_masterTableView();
                   var Rows = MasterTable.get_dataItems();
                   for (var i = 0; i < Rows.length; i++) {
 
                       var row = Rows[i];
                        
                       if (row.get_isInEditMode() == true) {
 
                           IsInEditmode = true;
 
                       }
                   }
 
               }
 
               if (IsInEditmode == true) {
                   // your grid is in edit mode
               }


Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Uday
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Uday
Top achievements
Rank 1
Share this question
or