StyleSelector ignored with AlternateRowStyle

6 posts, 0 answers
  1. Morgan McCollough
    Morgan McCollough avatar
    34 posts
    Member since:
    May 2010

    Posted 04 Apr 2011 Link to this post

    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?
  2. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 04 Apr 2011 Link to this post

    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
  3. DevCraft banner
  4. Morgan McCollough
    Morgan McCollough avatar
    34 posts
    Member since:
    May 2010

    Posted 04 Apr 2011 Link to this post

    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?
  5. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 04 Apr 2011 Link to this post

    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
  6. Anvarbek
    Anvarbek avatar
    7 posts
    Member since:
    Aug 2011

    Posted 29 Nov 2011 Link to this post

    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
  7. Anvarbek
    Anvarbek avatar
    7 posts
    Member since:
    Aug 2011

    Posted 29 Nov 2011 Link to this post


Back to Top
DevCraft banner