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

[Solved] Null value in CheckBox column

4 Answers 344 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Juan
Top achievements
Rank 1
Juan asked on 01 Sep 2010, 11:31 PM
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

4 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 02 Sep 2010, 07:40 AM
Hello,

 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.

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
Vlad
Telerik team
answered on 03 Sep 2010, 07:08 AM
Hi,

 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
Tags
GridView
Asked by
Juan
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Juan
Top achievements
Rank 1
Share this question
or