The grid is AutoGenerated=true so we don't have defined columns in the XAML.
In the grid (using the windows 7 theme) this value appears as a disabled, faint grey checkbox that is aligned left.
I need to be able to override this and lose the disabled state, but still be read only.
I need to be able to override this and align it properly to the center.
I need to be able to in the future, override this and replace the check box with "Yes/No"
Thanks
6 Answers, 1 is accepted
You can modify auto-generated columns using AutoGeneratingColumn event. In your case for example you can assign new CellTemplate for desired column or you can replace desired column with other column or your own custom column.
Kind regards,Vlad
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
I've tried a conditional style selector, I've tried just a straight data template.
My primary issue is I cannot determine the proper binding statement to use the Bound Value to the cell (The Boolean Value).
For example, in this code, the CheckedValueConverter gets the entire entity on the row. I don't know which column I am on in order to bind to the right entity property.
Ideally if I could I would just use a visibility converter on the checked path and use only one template instead of a selector, but again I don't know how to get to the cell's original property value.
<DataTemplate x:Key="ReadOnlyCheckedGrid">
<Grid HorizontalAlignment="Center" Height="13" VerticalAlignment="Center" Width="13">
<Border BorderBrush="Black" BorderThickness="1 1 1 1">
<Border BorderBrush="#FFEEEEEE" BorderThickness="1 1 1 1">
<Border BorderBrush="#FFB9B9B9" BorderThickness="1 1 1 1" Background="#FFE0E0E0">
<Grid Margin="0" x:Name="CheckBoxGrid">
<Path x:Name="CheckedPath" Data="M32.376187,77.162509 L35.056467,80.095277 40.075451,70.02144" HorizontalAlignment="Center"
Margin="0" Stretch="Fill" Stroke="Black" StrokeThickness="1.5" Visibility="Visible" VerticalAlignment="Center"/>
</Grid>
</Border>
</Border>
</Border>
</Grid>
</DataTemplate>
<DataTemplate x:Key="ReadOnlyUnCheckedGrid">
<Grid HorizontalAlignment="Center" Height="13" VerticalAlignment="Center" Width="13">
<Border BorderBrush="Black" BorderThickness="1 1 1 1">
<Border BorderBrush="#FFEEEEEE" BorderThickness="1 1 1 1">
<Border BorderBrush="#FFB9B9B9" BorderThickness="1 1 1 1" Background="#FFE0E0E0">
</Border>
</Border>
</Border>
</Grid>
</DataTemplate>
<Converters:CheckedValueConverter x:Key="CheckedValueConverter"/>
<Presentation:ConditionalDataTemplateSelector x:Key="CheckedGridTemplateSelector" ConditionConverter="{StaticResource CheckedValueConverter}">
<Presentation:ConditionalDataTemplateSelector.Rules>
<Presentation:ConditionalDataTemplateRule DataTemplate="{StaticResource ReadOnlyCheckedGrid}">
<Presentation:ConditionalDataTemplateRule.Value>
<sys:Boolean>True</sys:Boolean>
</Presentation:ConditionalDataTemplateRule.Value>
</Presentation:ConditionalDataTemplateRule>
<Presentation:ConditionalDataTemplateRule DataTemplate="{StaticResource ReadOnlyUnCheckedGrid}">
<Presentation:ConditionalDataTemplateRule.Value>
<sys:Boolean>False</sys:Boolean>
</Presentation:ConditionalDataTemplateRule.Value>
</Presentation:ConditionalDataTemplateRule>
</Presentation:ConditionalDataTemplateSelector.Rules>
</Presentation:ConditionalDataTemplateSelector>
if (e.ItemPropertyInfo.PropertyType == typeof(Boolean) || e.ItemPropertyInfo.PropertyType == typeof(Nullable<Boolean>) || e.ItemPropertyInfo.PropertyType == typeof(bool?)
|| e.ItemPropertyInfo.PropertyType == typeof(bool))
{
e.Column.CellTemplateSelector = Application.Current.Resources["CheckedGridTemplateSelector"] as ConditionalDataTemplateSelector;
}
If you do not know the property name you can use the Value property of GridViewCell for binding.
Greetings,Vlad
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Do you have any examples of how to do this with autogenerated columns?
Using AutoGenerateColumns, with an entity that is read only and has a boolean property, what can I do to update the style?
I've been trying around Blend and cannot find it.
The disabled Checkbox is hard for users to read.
Need to remove the disabled state.
Entity Client
Property bool IsActive
Entity Location
Property bool IsPrimary
Entity Phone
Property bool IsPrimary
Generally, to achieve this when autogenerating columns , the approach would be as follows :
1. Define your template in a static resource .
2. Handle the AutogeneratingColumn event of RadGridView.
3. Inside the event handler - check the DataType and set the template to the column , reading it from the static resource.
Yoan
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.