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

Setting GridViewToggleRowDetailsColumn background based on binding

10 Answers 100 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ganesh Shivshankar
Top achievements
Rank 1
Ganesh Shivshankar asked on 10 Aug 2012, 09:01 AM
Hi,

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

Sort by
0
Vlad
Telerik team
answered on 10 Aug 2012, 11:06 AM
Hi,

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.

0
Ganesh Shivshankar
Top achievements
Rank 1
answered on 10 Aug 2012, 11:30 AM
Hi Vlad,

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.
0
Vlad
Telerik team
answered on 10 Aug 2012, 11:32 AM
Hello,

 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.

Regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Ganesh Shivshankar
Top achievements
Rank 1
answered on 10 Aug 2012, 11:35 AM
Thanks for the link.

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.
0
Vlad
Telerik team
answered on 10 Aug 2012, 11:36 AM
Hi,

 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 &lt;= 10">
                                <Style TargetType="telerik:GridViewCell" />
                            </telerik:StyleRule>
                        </telerik:ConditionalStyleSelector>
                    </telerik:GridViewToggleRowDetailsColumn.CellStyleSelector>
                </telerik:GridViewToggleRowDetailsColumn>

Kind regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Ganesh Shivshankar
Top achievements
Rank 1
answered on 10 Aug 2012, 11:56 AM
Hi Vlad,

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?
0
Vlad
Telerik team
answered on 10 Aug 2012, 12:00 PM
Hi,

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>

Kind regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Ganesh Shivshankar
Top achievements
Rank 1
answered on 10 Aug 2012, 12:10 PM
Hi Vlad,

That didnt help either :(!
0
Vlad
Telerik team
answered on 10 Aug 2012, 12:13 PM
Hello,

 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.

0
Ganesh Shivshankar
Top achievements
Rank 1
answered on 10 Aug 2012, 12:28 PM
Creating a styleselector works. Thanks for the help.
Tags
GridView
Asked by
Ganesh Shivshankar
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Ganesh Shivshankar
Top achievements
Rank 1
Share this question
or