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

cannot set focus to griddropdowncolumn in edit mode

1 Answer 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
EJ
Top achievements
Rank 1
EJ asked on 19 Jun 2010, 12:23 PM
i tried to use a technique that works fine for GridMaskedColumn and GridNumericColumn but it does not work for GridDropDownColumn to set the focus to a particular row of the grid when it's displayed in edit mode

here's my column

<telerik:GridDropDownColumn DataField="id" DataSourceID="MyObjectDataSource" 
                                    HeaderText="Name" ListTextField="name" ListValueField="id" DataType="System.Guid" 
                                    UniqueName="id"
                                </telerik:GridDropDownColumn> 



and here's my code

Entity insertedRecordToSetFocusTo = null
        protected void MyRadGrid_ItemDataBound(object sender, GridItemEventArgs e) 
        { 
            // focus 
            if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode)) 
            { 
                GridEditableItem item = (GridEditableItem)e.Item; 
                if (insertedRecordToSetFocusTo != null) 
                { 
                    // check if we are at the row to set focus to 
                    if (item.GetDataKeyValue("id2").ToString() == insertedRecordToSetFocusTo.id2.ToString()) 
                    { 
                        RadComboBox c = (RadComboBox)item["id"].Controls[0]; 
                        c.Focus(); 
                        insertedRecordToSetFocusTo = null
                    } 
                } 
            } 
        } 

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 24 Jun 2010, 09:12 AM
Hi,

Here is a solution to the problem using RadScriptManager to set focus to the RadComboBox in edit mode:

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    
        if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode)) 
        
            GridEditableItem item = (GridEditableItem)e.Item; 
            RadComboBox c = (RadComboBox)item["ColumnUniqueName"].Controls[0]; 
            RadScriptManager1.SetFocus(c.ClientID + "_Input"); 
        
    }

Aditionaly, I just answered your support ticket as well, so if you have any further questions, let us please continue communication on the subject there, as it will be easier to keep track of each other's posts. Thank you.


Greetings,
Tsvetina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
EJ
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or