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

ItemStyle with SelectedItemStyle

2 Answers 23 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 14 Jul 2014, 05:54 PM
I have a RadGrid to which I've applied alternating row colors via CssClass attributes as recommended here:

<ItemStyle CssClass="GridItemStyle" />
<AlternatingItemStyle CssClass="GridAltItemStyle" />
<SelectedItemStyle CssClass="GridSelItemStyle" />

That works fine to style the rows using my zebra colors.  Now, I've added to the grid:

<MasterTableView AllowSorting="true" />

Now, when I click on a column header, the cells in the column by which I've sorted the data are not styled using my ItemStyle and AlternatingItemStyle CSS classes.  All of the <td/>s in the sorted column have class="rgSorted", yet they're zebra striped in the default grid alternating colours.  What gives?

(Rhetorical aside: Why don't ItemStyle-BackColor, AlternatingItemStyle-BackColor and SelectedItemStyle-BackColor just work the way they should?  Why is the recommended solution that we should use CSS to bypass your grid's own properties?  Shouldn't the recommended solution be to make the grid's published properties work with each other?  If we have to do it in CSS, your developers definitely can.)

So, about that screenshot, why is the sorted column ignoring my CSS row styles and reverting to the defaults?

Thank you,
~Jeff

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 15 Jul 2014, 04:32 AM
Hi Jeff,

By default RadGrid displays a special sort style for the sorted columns. The sort background depends on the skin.
If you want to disable this functionality, please set

ASPX:
<telerik:RadGrid>
  <SortingSettings EnableSkinSortStyles="false" />
</telerik:RadGrid>

Thanks,
Princy
0
Jeff
Top achievements
Rank 1
answered on 15 Jul 2014, 03:23 PM
Thank you, Princy.  I hadn't yet come across that property, which does just what I want.  (As everyone discovers quickly, the RadGrid can be overwhelming in its flexibility.)

Yesterday, I found another option, which at least gave me the ability to override the default styling, albeit sans any zebra styling of the rows, which is less than ideal:

<telerik:GridBoundColumn ... SortedBackColor="Tomato" />
<telerik:GridBoundColumn ... SortedBackColor="Tomato" />
<%-- et al --%>

(Not that I actually want "Tomato", mind you.)  If nothing else, this is another option as long as you explicitly define your grid's columns, which must be the case in most situations.

Cheers.
Tags
Grid
Asked by
Jeff
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Jeff
Top achievements
Rank 1
Share this question
or