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

[Solved] determine if item is in edit mode, client-side

2 Answers 218 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Charles Forsyth
Top achievements
Rank 2
Charles Forsyth asked on 12 Jun 2008, 02:24 AM
In JavaScript (client-side), how do you determine if a particular radGrid item is in edit mode or not?

Note: The index of the radGrid item is known.

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 12 Jun 2008, 04:25 AM
Hi Charles,

Go through the following forum link which discuss a similar scenario.
Client-side ItemType property

Thanks
Princy.
0
Charles Forsyth
Top achievements
Rank 2
answered on 12 Jun 2008, 04:02 PM
Thanks Princy.

However, I came up with my own solution:

// "element" is a paraemter for the function. It represents "this" from the onMouseDown event of the item row  
var draggedRowTD = element.getElementsByTagName("td")[0].innerHTML;  // get first td
var re = new RegExp('\<input[^\>]*?\>','gi'); // check for input form element  
if (draggedRowTD.match(re)) {  
    return false;  

The whole point was to stop dragging if the row is in edit mode. If it's not in edit mode it won't have an <input> in it. So I use regular expressions to find one in the first <td>'s innerHTML.

In my code behind, I set the event thusly...

    Private Sub RadGrid1_ItemCreated(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated  
        If TypeOf e.Item Is GridDataItem Then 
            Dim dataItem As GridDataItem = TryCast(e.Item, GridDataItem)  
            e.Item.Attributes("onmousedown") = String.Format("onGridMouseDown(event, this,{0})", dataItem.DataSetIndex)  
        End If 
    End Sub 
Tags
Grid
Asked by
Charles Forsyth
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Charles Forsyth
Top achievements
Rank 2
Share this question
or