This question is locked. New answers and comments are not allowed.
Hello,
I have a GridView where some of the columns are boolean values, but they are nullable booleans, so, sometimes some record could have a null value, I try what will happen in that case and the GridView renders a checkbox with a minus sign on it, a little imperceptible change, How can I redefine what will be presented in the case a null value arrives? Is there any Style or something that can be changed for that particular cell?
Juan Mejia
I have a GridView where some of the columns are boolean values, but they are nullable booleans, so, sometimes some record could have a null value, I try what will happen in that case and the GridView renders a checkbox with a minus sign on it, a little imperceptible change, How can I redefine what will be presented in the case a null value arrives? Is there any Style or something that can be changed for that particular cell?
Juan Mejia
4 Answers, 1 is accepted
0
Hello,
Vlad
the Telerik team
This is how standard CheckBox will look in case of IsThreeState set to true. You can create your own CheckBox (or style existing) and use CellTemplate to define it.
Best wishes,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
0
Juan
Top achievements
Rank 1
answered on 02 Sep 2010, 04:11 PM
I took the route of creating a Value Converter that returns a Style based on the Cell Value, and I want to apply such style to the CellStyle attribute of the GridViewDataColumn, but the GridView is ignoring the changes
I have the following code: For the Value Converter.
I have the following code: For the Value Converter.
public class TriStateBooleanToStyleValueConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
ResourceDictionary converterDictionary = new ResourceDictionary()
{
Source = new Uri("/SilverlightApplication1;component/Assets/Styles.xaml", UriKind.RelativeOrAbsolute)
};
if (value == null)
{
return converterDictionary["NullCellRedStyle"] as Style;
}
else
{
return converterDictionary["NullCellWhiteStyle"] as Style;
}
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
For the Styles defined in Styles.xaml<Style x:Key="NullCellRedStyle" TargetType="telerik:GridViewCell">
<Setter Property="Background" Value="#FFFFD8D8"/>
</Style>
<Style x:Key="NullCellWhiteStyle" TargetType="telerik:GridViewCell">
<Setter Property="Background" Value="#FFFFFFFF"/>
</Style>
Also have the Converter defined as a resource in the same styles file
<converters:TriStateBooleanToStyleValueConverter x:Key="TriBoolToStyle"/>
At the column level I have the following:
<telerik:GridViewDataColumn Header="To Pay" MinWidth="70" Width="90" DataMemberBinding="{Binding Path=ToPay}" CellStyle="{Binding Path=ToPay, Converter={StaticResource TriBoolToStyle}}" />The Checkbox in TriState is being rendered, and I want to add a background to make the value more visible. If I define the CellStyle directly without binding it works, but applies the selected style to all the cell in that column. How to achieve what I want?
Juan Mejia
0
Juan
Top achievements
Rank 1
answered on 02 Sep 2010, 04:14 PM
duplicated (ignore)
0
Hi,
Vlad
the Telerik team
You can check your other thread for more info.
All the best,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
