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

Setting focus in edit form - Master/Detail problem

1 Answer 81 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Declan
Top achievements
Rank 2
Declan asked on 23 Oct 2008, 10:46 AM
I am successfully setting focus in grids that are not Master/Detail using:

function focusDelivery(item) { 
    document.getElementById(item).focus(); 
    document.getElementById(item).scrollIntoView(); 

and in the ItemDataBound event

If (TypeOf (e.Item) Is GridEditFormItem) AndAlso e.Item.IsInEditMode Then  
    Dim box As TextBox = e.Item.FindControl("ContactName"
    grdDelivery.ClientSettings.ClientEvents.OnRowCreated = String.Format("focusDelivery('{0}')", box.ClientID) 
End If 
                    

My problem is that in a Master/Detail grid the databinding is in grid_DetailTableDataBind and I can't figure out how to get the e.Item values in order to check if it is an EditForm and IsInEditMode in order to set focus.

If (TypeOf (e.Item) Is GridEditFormItem) AndAlso e.Item.IsInEditMode Then 

Any help appreciated, thanks,

Declan

1 Answer, 1 is accepted

Sort by
0
Declan
Top achievements
Rank 2
answered on 23 Oct 2008, 11:35 AM
Solved!

Add to ItemDataBound event:

            If (TypeOf (e.Item) Is GridEditFormItem) AndAlso e.Item.IsInEditMode Then 
 
                If e.Item.OwnerTableView.Name = "Property" Then 
                    Dim box As TextBox = e.Item.FindControl("Address"
                    radGrid.ClientSettings.ClientEvents.OnRowCreated = String.Format("focusGrid('{0}')", box.ClientID) 
                Else 
                    Dim box As TextBox = e.Item.FindControl("FirstName"
                    radGrid.ClientSettings.ClientEvents.OnRowCreated = String.Format("focusGrid('{0}')", box.ClientID) 
 
                End If 
            End If 
Tags
Grid
Asked by
Declan
Top achievements
Rank 2
Answers by
Declan
Top achievements
Rank 2
Share this question
or