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

How to set the color of the selected row in a RadGridView

4 Answers 312 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Unisense
Top achievements
Rank 1
Unisense asked on 17 Oct 2014, 08:51 AM
Hi Telerik,

I have this RadGridView:

<telerik:RadGridView IsFilteringAllowed="False" BorderBrush="#9AB400" Name="gridView" Grid.Column="0" ItemsSource="{Binding ChamberMeasurements}" AutoGenerateColumns="True" Margin="120,10,12,0" VerticalAlignment="Top" ShowGroupPanel="False">
</telerik:RadGridView>

When i click a row in the table created by the RadGridView then the selected row is not highlighted and i don't understand why. Should i set the color of the selected row somehow?

The ChamberMeasurements property is of type DataTable.

Can you tell me if i am doing something wrong or missing something?

Best regards,
Jeppe

4 Answers, 1 is accepted

Sort by
0
Boris
Telerik team
answered on 22 Oct 2014, 08:23 AM
Hello Jeppe,

It's strange that the selected row is not highlighted. In your application do you use NoXAML binaries with Implicit.Themes and if you do did you modify the theme in any way? 

I attached a sample project that is bound to a DataTable, however the selected row is highlighted as expected. 

Could you please examine your project and the attached one for any differences regarding the selection and provide us with additional information about your case? 

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
Unisense
Top achievements
Rank 1
answered on 23 Oct 2014, 07:57 AM
Hi Boris,

I have spent a lot of time examining the differences and found that the table was at some point refreshed with data and therefore the selected value was removed.

So a new question:
How do i programmatically select a row in a RadGridView afterwards?

I have tried something like this to save the selected item:
var item = gridView.SelectedItem as DataRow;
_selectedRow = item;

and later, when the table has been refreshed to set this item again as the SelectedItem:
gridView.SelectedItem = _selectedRow;

But this does not work.

Best regards,
Jeppe
0
Dimitrina
Telerik team
answered on 23 Oct 2014, 11:32 AM
Hello Jeppe,

Would you please check if the instance of _selectedRow exists in gridView.Items' collection?

Regards,
Dimitrina
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
Unisense
Top achievements
Rank 1
answered on 24 Oct 2014, 06:19 AM
Hi Dimitrina,

I have managed to afterwards highlight the selected row, it work like this:

foreach (var item in gridView.Items)
{
    var datarow = item as DataRow;
    if (datarow != null && (datarow["Chamber"].ToString() == viewModel.SelectedChamberNr.ToString()))
    {
        gridView.SelectedItem = item;
    }
}


Where the column Chamber is a unique identifier for a row.

Best regards,
Jeppe
Tags
General Discussions
Asked by
Unisense
Top achievements
Rank 1
Answers by
Boris
Telerik team
Unisense
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or