Setting GridViewToggleRowDetailsColumn background based on binding

11 posts, 0 answers
  1. Ganesh Shivshankar
    Ganesh Shivshankar avatar
    78 posts
    Member since:
    Sep 2009

    Posted 10 Aug 2012 Link to this post

    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
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 10 Aug 2012 Link to this post

    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.

  3. Ganesh Shivshankar
    Ganesh Shivshankar avatar
    78 posts
    Member since:
    Sep 2009

    Posted 10 Aug 2012 Link to this post

    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.
  4. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 10 Aug 2012 Link to this post

    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.

  5. Ganesh Shivshankar
    Ganesh Shivshankar avatar
    78 posts
    Member since:
    Sep 2009

    Posted 10 Aug 2012 Link to this post

    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.
  6. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 10 Aug 2012 Link to this post

    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.

  7. Ganesh Shivshankar
    Ganesh Shivshankar avatar
    78 posts
    Member since:
    Sep 2009

    Posted 10 Aug 2012 Link to this post

    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?
  8. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 10 Aug 2012 Link to this post

    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.

  9. Ganesh Shivshankar
    Ganesh Shivshankar avatar
    78 posts
    Member since:
    Sep 2009

    Posted 10 Aug 2012 Link to this post

    Hi Vlad,

    That didnt help either :(!
  10. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 10 Aug 2012 Link to this post

    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.

  11. Ganesh Shivshankar
    Ganesh Shivshankar avatar
    78 posts
    Member since:
    Sep 2009

    Posted 10 Aug 2012 Link to this post

    Creating a styleselector works. Thanks for the help.
Back to Top