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

RadGridView Row ForeColor

8 Answers 140 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ravi
Top achievements
Rank 1
Ravi asked on 06 May 2011, 12:07 PM
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

8 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 06 May 2011, 12:41 PM
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
0
Ravi
Top achievements
Rank 1
answered on 06 May 2011, 01:03 PM
I am looking forward to set the FORECOLOR, not the BackColor

0
Rossen Hristov
Telerik team
answered on 06 May 2011, 01:14 PM
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
0
Ravi
Top achievements
Rank 1
answered on 06 May 2011, 02:42 PM
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
0
Rossen Hristov
Telerik team
answered on 06 May 2011, 02:58 PM
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
0
Ravi
Top achievements
Rank 1
answered on 06 May 2011, 03:29 PM
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
0
Ravi
Top achievements
Rank 1
answered on 09 May 2011, 07:03 AM
Hi Ross,

Do you have alternative suggestion for the same.

Thanks,
Shiras
0
Vanya Pavlova
Telerik team
answered on 09 May 2011, 07:18 AM
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
Tags
GridView
Asked by
Ravi
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Ravi
Top achievements
Rank 1
Vanya Pavlova
Telerik team
Share this question
or