I'm trying to set the background on GridViewToggleRowDetailsColumn based on a Type field in the ItemsSource. How do I achieve this?
Thanks.
Ganesh
10 Answers, 1 is accepted
Can you post more info what you've tried so far? Have you tried CellStyleSelector as shown on our demos and documentation?
Greetings,Vlad
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
I have set a implict style for the toggle button on the column because we want a red + icon and it works. How do I set the cellstyleselector? Can you point me to the link in the demo?
Thanks.
You can check this demo for more info:
http://demos.telerik.com/silverlight/#GridView/Selectors/StyleSelectors/DeclarativeDefinition
The demo is working with plain GridViewDataColumn however you can apply the same for GridViewToggleRowDetailsColumn to style the cell.
Vlad
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
But the GridViewToggleRowDetailsColumn doesnt seem to have a DataMemberBinding column. So I dont think I can really bind my Type field to it. Can you send acorss a sample if you dont mind?
Thanks.
As I said in my previous reply you do not have to have DataMemberBinding (GridViewDataColumn) to apply style selector:
<telerik:GridViewToggleRowDetailsColumn>
<telerik:GridViewToggleRowDetailsColumn.CellStyleSelector>
<telerik:ConditionalStyleSelector>
<telerik:StyleRule Condition="ID > 10">
<Style TargetType="telerik:GridViewCell">
<Setter Property="Background"
Value="Red" />
<Setter Property="Foreground"
Value="Blue" />
</Style>
</telerik:StyleRule>
<telerik:StyleRule Condition="ID <= 10">
<Style TargetType="telerik:GridViewCell" />
</telerik:StyleRule>
</telerik:ConditionalStyleSelector>
</telerik:GridViewToggleRowDetailsColumn.CellStyleSelector>
</telerik:GridViewToggleRowDetailsColumn>
Vlad
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
I tried this, but doesnt seem to work.
<telerik:GridViewToggleRowDetailsColumn.CellStyleSelector>
<TelerikRadControl:ConditionalStyleSelector>
<telerik:StyleRule Condition="Type != 'P'">
<Style TargetType="telerik:GridViewCell">
<Setter Property="Background" Value="#DE6163" />
</Style>
</telerik:StyleRule>
<TelerikRadControl:StyleRule Condition="Type == 'P'">
<Style TargetType="telerik:GridViewCell">
<Setter Property="Background" Value="#39517B" />
</Style>
</TelerikRadControl:StyleRule>
</TelerikRadControl:ConditionalStyleSelector>
</telerik:GridViewToggleRowDetailsColumn.CellStyleSelector>
What am I doing wrong here?
You can try this instead:
<telerik:GridViewToggleRowDetailsColumn.CellStyleSelector>
<TelerikRadControl:ConditionalStyleSelector>
<telerik:StyleRule Condition="Not Type = 'P'">
<Style TargetType="telerik:GridViewCell">
<Setter Property="Background" Value="#DE6163" />
</Style>
</telerik:StyleRule>
<TelerikRadControl:StyleRule Condition="Type = 'P'">
<Style TargetType="telerik:GridViewCell">
<Setter Property="Background" Value="#39517B" />
</Style>
</TelerikRadControl:StyleRule>
</TelerikRadControl:ConditionalStyleSelector>
</telerik:GridViewToggleRowDetailsColumn.CellStyleSelector>
Vlad
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
That didnt help either :(!
In this case maybe you should try normal style selector instead declarative where you can easily debug your scenario to see what's going on. You can check all other style selector demos for more info.
Greetings,Vlad
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.