RadGridView Row ForeColor

9 posts, 0 answers
  1. Ravi
    Ravi avatar
    104 posts
    Member since:
    Oct 2012

    Posted 06 May 2011 Link to this post

    Hi,

    I want to programatically set the forecolor of the radgridview row. not cell by cell.

    1) please so let me know which all event i can set the forecolor.
    2) Will it possible to iterate through the grid and set the forecolor for the entire row. not cell by cell

    my intention is, i have two IList, i want to compare both the List and get the equivalent value and set the forecolor for the matching records.

    I am using Q1, 2011 Version.

    Thanks,
    Shiras
  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 06 May 2011 Link to this post

    Hello David,

    I believe that the feature you are looking for is the Row Style Selector. It is documented here.

    Let us know if this is not what you are after.

    Regards,
    Ross
    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. Ravi
    Ravi avatar
    104 posts
    Member since:
    Oct 2012

    Posted 06 May 2011 Link to this post

    I am looking forward to set the FORECOLOR, not the BackColor

  5. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 06 May 2011 Link to this post

    Hello David,

    You can set absolutely any property of an element with a Style. It is not just the Background property. This particular example sets the Background property, because it is just an example.

    But you can set any other property in absolutely the same way, including the Foreground property. Simply replace the word Background with the word Foreground.

    Please, take a look at this article before you go on.

    I hope this helps.

    All the best,
    Ross
    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. Ravi
    Ravi avatar
    104 posts
    Member since:
    Oct 2012

    Posted 06 May 2011 Link to this post

    I have already have rowstyle defined in the grid. I have implemented the hierarchical grid. The need of the below style was i dint want any space between the parent and child grid. basically padding = 0.

    <dgRowStyle:CustomGridViewRowStyle x:Key="rowExistingStyle">
            <dgRowStyle:CustomGridViewRowStyle.rowExistingStyle>
                <Style TargetType="telerik:GridViewRow">
                    <Setter Property="Foreground" Value="Red"/>
                </Style>
            </dgRowStyle:CustomGridViewRowStyle.rowExistingStyle>
            <dgRowStyle:CustomGridViewRowStyle.rowNormalStyle>
                <Style TargetType="telerik:GridViewRow">
                    <Setter Property="Foreground" Value="Black" />
                </Style>
            </dgRowStyle:CustomGridViewRowStyle.rowNormalStyle>
        </dgRowStyle:CustomGridViewRowStyle>

    now for the row forecolor I am using the RowStyleSelector in the same grid. so its not going to StyleSelector class.

    So I request you to please help me in merging these two requirements.

    1) I dont want space between the Parent and Child grid in a Hierarchical grid.
    2) based on one of the propery of my model class, the forecolor of the grid should differ.

    below is the code for forecolor (from the example you gave in this support)

    <dgRowStyle:CustomGridViewRowStyle x:Key="rowExistingStyle">
            <dgRowStyle:CustomGridViewRowStyle.rowExistingStyle>
                <Style TargetType="telerik:GridViewRow">
                    <Setter Property="Foreground" Value="Red"/>
                </Style>
            </dgRowStyle:CustomGridViewRowStyle.rowExistingStyle>
            <dgRowStyle:CustomGridViewRowStyle.rowNormalStyle>
                <Style TargetType="telerik:GridViewRow">
                    <Setter Property="Foreground" Value="Black" />
                </Style>
            </dgRowStyle:CustomGridViewRowStyle.rowNormalStyle>
        </dgRowStyle:CustomGridViewRowStyle>

    Both individually is working. I want both the functionality,

    Thanks
  7. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 06 May 2011 Link to this post

    Hello David,

    You can't mix both. When you use a StyleSelector it will set the Style of the row and it will thus overwrite the RowStyle that you have defined.

    Can't you move this padding setting (and anything else that you need) to all of the different styles that you will define. For example:

    <Style x:Key="RedStyle" TargetType="telerik:GridViewRow">
        <Setter Property="Foreground" Value="Red" />
        <Setter Property="Padding" Value="0" />
    </Style>
     
    <Style x:Key="BlackStyle" TargetType="telerik:GridViewRow">
        <Setter Property="Foreground" Value="Black" />
        <Setter Property="Padding" Value="0" />
    </Style>

    In this way, no matter whether the row is black or red -- its padding will always be zero.

    I hope this helps.

    Greetings,
    Ross
    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
  8. Ravi
    Ravi avatar
    104 posts
    Member since:
    Oct 2012

    Posted 06 May 2011 Link to this post

    Hi Ross,

    I moved the padding as you mentioned to the StyleSelector. And  I removed the the RowStyle. Now the row color works fine. but the gap between the parent and child is coming which my client will not accept.

    If I am able to remove the gap between the parent and child in the StyleSelector, I am done. Please let me know your thoughts.

    <Style x:Key="GridViewRowStyle1" TargetType="telerik:GridViewRow">
            <Setter Property="IsTabStop" Value="False"/>
            <Setter Property="Template" Value="{StaticResource GridViewRowTemplate}"/>
            <Setter Property="Background" Value="{StaticResource ItemBackground}"/>
            <Setter Property="BorderBrush" Value="{StaticResource GridView_GridLinesItemBorder}"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="FontWeight" Value="Normal"/>
            <Setter Property="VerticalContentAlignment" Value="Stretch"/>
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            <Setter Property="Padding" Value="0"/>
        </Style>

    The above is how I have set the RowStyle. What i did is I moved all the Setter from the this to my RowStyleSelector.  but still the gap is there between Parent and Child grids.

    I appreciate your followup and quick response.

    Thanks
  9. Ravi
    Ravi avatar
    104 posts
    Member since:
    Oct 2012

    Posted 09 May 2011 Link to this post

    Hi Ross,

    Do you have alternative suggestion for the same.

    Thanks,
    Shiras
  10. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 09 May 2011 Link to this post

    Hi David,

     

    You cannot change the gap between child tables using simple style.
    If you take a look at the default template of GridViewRow, you may see the HierarchyChildPresenter which is responsible for displaying child tables. Through editing its template just remove the default Padding of the Border element surrounding this presenter (please refer to the attached picture and to the sample project). 
    Then you may use this style in the corresponding StyleSelector. 


    Kind 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
Back to Top
DevCraft banner