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

Dynamically code added columns require double tab to activate

2 Answers 58 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Chris
Top achievements
Rank 1
Chris asked on 02 Jun 2014, 12:09 PM
My Silverlight RadGridView requirement is such that I have a grid with a set number of columns that are defined at design time.  Then, depending on the data set that is loaded, I have to dynamically add N additional columns to the grid.  Each dynamic column needs to be unbound and have the ability have text entered.

The approach I took was to define a DataTemplate as a page resource and then use the DataTemplate as a CellTemplate for each run-time created column.  The data template is defined simply as a <TextBox>.

Everything loads and displays correctly.  The issue, however, is that when I tab through the grid and come to one of the dynamically added columns, I have to tab twice to be able to enter the data (once to gain focus on the column and again to gain focus on the textbox).  Then, sometimes when I tab out and then tab back over the cell to which I entered data, the data will be erased.

What am I missing so that the grid behaves as it should, and expected?  That is, only have to tab once between cells to enter data in the dynamically added cell and then not loose any data?

Thanks.

2 Answers, 1 is accepted

Sort by
0
Chris
Top achievements
Rank 1
answered on 02 Jun 2014, 08:00 PM
I've tried setting EditTriggers="CellClick" at the grid level but that still does not give me the desired outcome.  The cells in which I need the textbox controls are dynamically so I do not know how to set EditTriggers for the individual columns through code.
0
Dimitrina
Telerik team
answered on 04 Jun 2014, 01:43 PM
Hi,

I tested defining some columns at design time like so:
<telerik:GridViewDataColumn>
   <telerik:GridViewDataColumn.CellTemplate>
       <DataTemplate>
           <TextBox/>
       </DataTemplate>
   </telerik:GridViewDataColumn.CellTemplate>
  </telerik:GridViewDataColumn>

I still need to tab two times, so that I get the focus inside the TextBox defined as CellTemplate.
You say that you need to Tab once between the initially defined columns - how have you defined the columns at design time?

Generally, you can redefine how the GridView handles the "Tab" key (and other keys) creating your own custom keyboard provider. Please refer to our online documentation for further details. It also shows some sample code.

Regards,
Didie
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GridView
Asked by
Chris
Top achievements
Rank 1
Answers by
Chris
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or