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

How can I set focus to text box inside a datatemplate?

5 Answers 192 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jerry Kurata
Top achievements
Rank 1
Jerry Kurata asked on 27 May 2011, 09:34 PM
Hi,

I have a datatemplate for each row in the grid.  I am trying to ensure that when the user creates a new row they are left in edit mode in a text box that is part of the template.  Does anyone have an example I can review?

One potential complexity is that my data template is defined in a ResourceDictionary.

thanks,

jerry

5 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 01 Jun 2011, 04:47 PM
Hello Jerry Kurata,

Would you please shed some more light on your custom template structure? Where do you intend to place this DataTemplate? Meanwhile, you may refer to our Custom Row Layout example. it might prove useful.

Kind regards,
Ivan Ivanov
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
0
Jerry Kurata
Top achievements
Rank 1
answered on 01 Jun 2011, 05:31 PM
Hi,

The datatemplate would be used to represent the cell content such as:
<DataTemplate>
      <TextBox x:name="txtvalue" width="100"  />
</DataTemplate>
The row containing the cell would be added to the grid by a user dropping onto the grid.  At that time we create the row and want to have the focus in the textbox in the newly created row so the user can start entering text without having to select the textbox with their mouse.

Thanks,

Jerry
0
Ivan Ivanov
Telerik team
answered on 06 Jun 2011, 02:22 AM
Hi Jerry Kurata,

As you are using a quite simple cell template without changing the internal template structure of RadGridView, I would advise you to execute the RadGridViewCommands.BeginInsert command, when you are about to add a new row to the grid. If I have understood you requirements properly, this approach will save you a lot of effort and the results will be quite similar to the desired ones.

Best wishes,
Ivan Ivanov
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
0
Anirban
Top achievements
Rank 1
answered on 29 Sep 2011, 06:43 PM
Hi,

I am having the same issue. I have a text box inside a DataTemplate . The TextBox is placed inside a StackPanel and the DataTemplate is been accessed to the View through Merged Dictionary. Now when the View loads up, the Focus should be set on that TextBox .

It would be great if you could provide some details on this.

Thanks,
Anirban
0
Ivan Ivanov
Telerik team
answered on 04 Oct 2011, 01:44 PM
Hello Anirban,

Unfortunately there is no clean approach to subscribe to any event of your DataTemplate's elements, as it is stored in a ResourceDictionary. Would you please clarify where exactly do you load this template in RadGridView, so that we could propose you a solution that utilizes a proper RadGridView event? 

Greetings,
Ivan Ivanov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Tags
GridView
Asked by
Jerry Kurata
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Jerry Kurata
Top achievements
Rank 1
Anirban
Top achievements
Rank 1
Share this question
or