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

RadGridView SelectedItem does not update correctly

3 Answers 691 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jerry
Top achievements
Rank 1
Jerry asked on 27 Oct 2014, 02:29 PM
I'm using the RadGridView control to display an Observable collection. I also use SelectedItem="{Binding Model.CurrentRow, Mode=TwoWay}" to track which item in the list the grid pointer is on.

The first column in the grid has a textbox so the user can change the value in the grid. I subscribe to a property change event to validate the content in the textbox.

The other columns in the grid are not editable.

----
The problem:
----
When I click on any non-editable column in the grid, the grid Row highlights correctly and the "Model.CurrentRow" updates correctly. However, when I click on a textbox in the first column on a non selected row, that row does NOT receive focus. The grid row focus stays on the prevously selected row, and the "Model.CurrentRow" does not update.

How can I make the grid row focus on the selected row when i click on an editable textbox in the grid?

My partial RadGridView xaml:

<gridControls:RadGridView
                ........
                AutoGenerateColumns="False"
                CanUserDeleteRows="False"
                CanUserFreezeColumns="False"
                CanUserInsertRows="False"
                IsFilteringAllowed="False"
                IsReadOnly="False"
                RowIndicatorVisibility="Collapsed"
                SelectionUnit="FullRow"
                ShowGroupPanel="False"
                ItemsSource="{Binding Model.MyList}"
                SelectedItem="{Binding Model.CurrentRow, Mode=TwoWay}">

<gridControls:RadGridView.Columns>

   <gridControls:GridViewColumn
    Header="Company Name"
    IsReadOnly="True"
   Width="200" >
    <gridControls:GridViewColumn.CellTemplate>
     <DataTemplate>
       <TextBox Text="{Binding CompanyName, Mode=TwoWay}"/>
     </DataTemplate>
     </gridControls:GridViewColumn.CellTemplate>
    </gridControls:GridViewColumn>

                        <gridControls:GridViewDataColumn
                        DataMemberBinding="{Binding CustomerType}"
                        Header="Customer Type"
                        IsReadOnly="True"
                        Width="125"
                        />
...........

3 Answers, 1 is accepted

Sort by
0
Boris
Telerik team
answered on 29 Oct 2014, 04:41 PM
Hi Jerry,

Generally RadGridView supports selection out-of-the-box. However, in your case, you want to perform this action using a control placed in CellTemplate of the column(the TextBox).  If you click on the cell which contains the control, you will actually click in the TextBox instead of GridViewRow/GridViewCell, so RadGridView's selection logic will not work. 

For more information about CellTemplate / CellEditTemplate you can check the Setting CellTemplate and CellEditTemplate documentation article.

I hope this helps.

Regards,
Boris Penev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Rajendra
Top achievements
Rank 1
answered on 25 Oct 2017, 12:08 PM
Im facing issues while selecting multiple items in RadGridView using Select() method provided by RadGridView itself. Sometimes SelectedItems are shown properly but sometimes it does not show SelectedItems correctly even when I am passing correct arguments to Select() method. Could you please guide us on what could be the issue?
0
Stefan
Telerik team
answered on 30 Oct 2017, 09:59 AM
Hi Rajendra,

With the provided information I can only be guessing what the cause for such behavior is. Can you please demonstrate how exactly are you performing the selection of the control, so I can assist you further?

Thanks in advance for your cooperation.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
Jerry
Top achievements
Rank 1
Answers by
Boris
Telerik team
Rajendra
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or