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

[Solved] Determining whether a row is in edit mode in client-side javascript

1 Answer 168 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tom
Top achievements
Rank 1
Tom asked on 27 Oct 2009, 10:15 AM
Hi

Just upgrading our prototype product from RadControls Q1 2007 to RadControls Q2 2009, which in itself has been a bit of a leap ... but the majority of it has worked fine. There is one control that I'm currently upgrading which uses a bit more client side script then every other section of the associated web projects.

The problem I have is that on the original client side object model, you could query a row's `ItemType` member, when referring to a row object from the rows collection of a table view:

for (var i = 0; i < rows.length; i++) { 
    if (rows[i].ItemType == "EditItem") { editedRow = rows[i]; break; } 
}     

During migration process, I have revised the code and now initialise my rows variable in the above example with the following:

var view = grid.get_masterTableView(); 
var rows = view.get_dataItems(); 

But for the life of me, I can't find anything equivalent of a row/GridItem `ItemType` in the Q2 2009 client side object model, and the client-side API reference is a little thin- I've found a lot of control functions relating to editing items, e.g:

masterTable.editItem(masterTable.get_dataItems()[0].get_element()); 
 
masterTable.editSelectedItems(); 
 
masterTable.updateEditedItems(); 
 
masterTable.editAllItems(); 

But these all change the state of the items when all I want to know is what state the item is in. Is there a collection of GridItems that are dangling off the edge of the object model somewhere, or a simple property I'm missing or a function to evaluate? Please help!

Thanks


Tom

1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 28 Oct 2009, 07:07 AM
Hello Tom,

Generally you can check whether the hierarchical index of the item is in the _editIndexes collection of RadGrid. For example:
1.var myDatItemIndex = $find('RadGrid1').get_masterTableView().get_dataItems()[0]._itemIndexHierarchical;
2.  
3.var isInEditMode = Array.contains($find('RadGrid1')._editIndexes,myDatItemIndex);


Regards,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Tom
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question
or