This question is locked. New answers and comments are not allowed.
Hi,
I am using a telerik RadGrid. I display double values in the grid. And the footer column has the Grand Total of the double values.
I have applied a NegativeNumberConverter to all the double values so that if a value is negative, then it is diplayed with brackets aound it and is comma separated.
Also if the value is negative, it is displayed in red color using StyleSelector.
I want to apply similar Converter and formatting to my footer row as well.
The XAML is follows:
Please suggest how to do this.
Thanks.
I am using a telerik RadGrid. I display double values in the grid. And the footer column has the Grand Total of the double values.
I have applied a NegativeNumberConverter to all the double values so that if a value is negative, then it is diplayed with brackets aound it and is comma separated.
public
object
Convert(
object
value, Type targetType,
object
parameter, System.Globalization.CultureInfo culture)
{
Double doubleValue = Double.Parse(value.ToString());
if
(doubleValue < 0)
return
(
"(-)"
+ Math.Abs(doubleValue)).ToString();
if
(
double
.TryParse(value.ToString(),
out
doubleValue))
return
doubleValue.ToString(
"N"
);
}
Also if the value is negative, it is displayed in red color using StyleSelector.
public
class
TotalStyleSelector : StyleSelector
{
public
override
Style SelectStyle(
object
item, DependencyObject container)
{
var style =
new
Style(
typeof
(GridViewCell));
var cell = (GridViewCell)container;
var obj = (InventoryAnalysisEntity)item;
if
(obj.Total < 0)
{
style.Setters.Add(
new
Setter(GridViewCell.ForegroundProperty,
new
SolidColorBrush(Colors.Red)));
}
return
style;
}
}
I want to apply similar Converter and formatting to my footer row as well.
The XAML is follows:
<
telerik:GridViewDataColumn
Header
=
"0-30 D"
CellStyleSelector
=
"{StaticResource d0_30StyleSelector}"
DataMemberBinding
=
"{Binding Path=D0_30, Converter={StaticResource NegativeNumberConverter}}"
IsFilterable
=
"False"
TextAlignment
=
"Right"
HeaderTextAlignment
=
"Center"
HeaderCellStyle
=
"{StaticResource IntranetGridViewHeaderCellStyle}"
FooterCellStyle
=
"{StaticResource IntranetGridViewFooterCellStyle}"
>
<
telerik:GridViewDataColumn.AggregateFunctions
>
<
telerik:SumFunction
ResultFormatString
=
"{}{0:N}"
/>
</
telerik:GridViewDataColumn.AggregateFunctions
>
<
telerik:GridViewColumn.CellTemplateSelector
>
<
local:D0_30Template
>
<
local:D0_30Template.EmptyDataTemplate
>
<
DataTemplate
>
<
TextBlock
/>
</
DataTemplate
>
</
local:D0_30Template.EmptyDataTemplate
>
</
local:D0_30Template
>
</
telerik:GridViewColumn.CellTemplateSelector
>
</
telerik:GridViewDataColumn
>
Please suggest how to do this.
Thanks.