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

Need to have colour red or green on one column

1 Answer 36 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Phil Kestenbaum
Top achievements
Rank 1
Phil Kestenbaum asked on 10 Aug 2010, 09:13 PM

HI The following code displays an amount, the summary available, that the product category has left in relation to its budget. What I would like is if the number if negative, it should have a red color, indicating over budget, and if not, it should be in green.

 

 

 

 

 

 

 

</telerik:GridViewDataColumn>

 

 

 

 

 

<telerik:GridViewDataColumn DataMemberBinding="{Binding Summary.Available}" Header="Available" TextAlignment="Right" DataFormatString="$ {0:#,##0.00}" FooterTextAlignment="Right" >

 

 

 

 

 

<telerik:GridViewDataColumn.AggregateFunctions>

 

 

 

 

 

<data:SumFunction SourceField="Summary.Available" ResultFormatString="$ {0:#,##0.00}" />

 

 

 

 

 

</telerik:GridViewDataColumn.AggregateFunctions>

 

 

 

 

 

</telerik:GridViewDataColumn>

 

 

 

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 11 Aug 2010, 06:23 AM
Hi,

 

You can declare custom Footer for this column similar to the third column in this demo. Here is an example:

<telerik:GridViewDataColumn.Footer>
<StackPanel Orientation="Vertical" Margin="5,0">
<TextBlock Text="Custom footer with aggregates:" Margin="0,0,0,2" />
<telerik:AggregateResultsList ItemsSource="{Binding}" VerticalAlignment="Center" Grid.Column="4">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock VerticalAlignment="Center" Text="{Binding Caption}" />
<TextBlock VerticalAlignment="Center" Text="{Binding FormattedValue}" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</telerik:AggregateResultsList>
</StackPanel>
</telerik:GridViewDataColumn.Footer>

To achieve your goal you can set Foreground for the value TextBlock with IValueConverter. 

Sincerely yours,
Vlad
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
Phil Kestenbaum
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or