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

StyleSelector ignored with AlternateRowStyle

5 Answers 120 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Morgan McCollough
Top achievements
Rank 1
Morgan McCollough asked on 04 Apr 2011, 06:43 PM
I was looking at using the StyleSelector to do some conditional formatting in our grids. Originally we did this by adding a custom binding in the RowLoaded event because the selector wasn't working right (several releases back).

Anyway, I am now revisiting the StyleSelector (build 2011.1.322.1040), and it seems to work except for the fact that it is only used on every other row. It seems that if you use a style selector in conjunction with AlternateRowStyle, the selector is ignored on rows that have the alternate style, even if the properties being set in the 2 styles do not overlap. My style selector uses styles that only set the Foreground color, while the alternate row style sets the background color. Shouldn't the styles be merged?

Has anyone else seen this?

5 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 04 Apr 2011, 06:57 PM
Hi Morgan,

 

The behavior you described is the expected one. When you have combined a style targeted at GridViewRow and GridViewRow StyleSelector, the style always takes predecence, it is by design. This is the reason by which the defined StyleSelector is ignored. In such cases you may define only a single StyleSelector that corresponds to your custom needs.


If you need any additional information please let us know.


Regards,
Vanya Pavlova
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
Morgan McCollough
Top achievements
Rank 1
answered on 04 Apr 2011, 07:08 PM
Oh. That's unfortunate. So you can't use alternating styles at the same time. So, I would need to re-implement my alternating row style in the custom StyleSelector, yes? How would I do that?
0
Vanya Pavlova
Telerik team
answered on 04 Apr 2011, 07:23 PM
Hello Morgan,

 

You may define an AlternateRowStyleSelector in the same way as it can be done with RowStyleSelector, please refer to the markup below:

<telerik:RadGridView AutoGenerateColumns="False" ItemsSource="{Binding}" AlternateRowStyleSelector="{StaticResource styleSelector}" > .... </telerik:RadGridView>


Furthermore if you need to set only the background for these alternate rows why not just set the AlternateRowBackground property of RadGridView to specific colour. Then you may apply the RowStyleSelector in an appropriate manner.


Please let me know how this works for you.

 

Best wishes,
Vanya Pavlova
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
Anvarbek
Top achievements
Rank 1
answered on 29 Nov 2011, 05:06 PM
Hi Vanya,

I have set the AlternateRowBackground to "PapayaWhip" but RowStyleSelector is still ignored for the rows where Alternate is activated.

is there any other workaround ?

Regards,
Bek
0
Anvarbek
Top achievements
Rank 1
answered on 29 Nov 2011, 05:06 PM

Tags
GridView
Asked by
Morgan McCollough
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Morgan McCollough
Top achievements
Rank 1
Anvarbek
Top achievements
Rank 1
Share this question
or