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

Null Value Display

3 Answers 95 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Terry Foster
Top achievements
Rank 1
Terry Foster asked on 07 Aug 2010, 05:58 PM
Hi,

I've got a 'GridViewComboBoxColumn' that is bound to a property that allows nulls.  I apply styles to the 'RadComboBox' editor to set the 'EmptyText' property to a custom string (I don't want it to be an empty string, which is the default).  This works great when the cell is in edit mode, but when it's not, the cell is blank.  I tried setting a converter on the column binding, but it doesn't seem to work (everything in that column goes blank).  How can I achieve this?  Ideally, it would awesome if, by default, you guys displayed the 'EmptyText' property of the 'RadComboBox'.

Thanks,
Terry

3 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 11 Aug 2010, 04:13 PM
Hi Terry Foster,

The  element in display mode is a different instance from the element in edit mode. To target both you may try something like :
<Grid x:Name="LayoutRoot" Background="White">
       <Grid.Resources>
           <Style TargetType="telerik:RadComboBox">
               <Setter Property="EmptyText" Value="(None)" />
           </Style>
       </Grid.Resources>
       <twcg:RadGridView x:Name="_gridView" AutoGenerateColumns="False"/>
   </Grid>

This should solve the problem .

Greetings,
Pavel Pavlov
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
Terry Foster
Top achievements
Rank 1
answered on 11 Aug 2010, 04:47 PM
Thanks, Pavel - that seems to work great.  However, I need to display different text for different combo box columns.  I tried setting the CellStyle for the column, but this throws a weird exception.

	column.EditorStyle = new Style(typeof(RadComboBox));
column.EditorStyle.Setters.Add(new Setter(RadComboBox.EmptyTextProperty, EmptyText));
column.EditorStyle.Setters.Add(new Setter(RadComboBox.ClearSelectionButtonVisibilityProperty, Visibility.Visible));
column.EditorStyle.Setters.Add(new Setter(RadComboBox.ClearSelectionButtonContentProperty, EmptyText));

column.CellStyle = new Style(typeof(RadComboBox));
column.CellStyle.Setters.Add(new Setter(RadComboBox.EmptyTextProperty, EmptyText));

How can this be achieved?  Also, can you explain why a value converter doesn't work.  I'm really trying to understand.

Thanks,
Terry
0
Pavel Pavlov
Telerik team
answered on 12 Aug 2010, 01:16 PM
Hello Terry Foster,

Ok , setting different values for each combo column would be a bit more complicated but still possible.

For the edit mode - EditorStyle works fine.
For the display mode , we need to set a different cell template , and specify the empty text inside.
The attached project demonstrates how to set the text for the display mode of the cell. ( specific for the column ) .


All the best,
Pavel Pavlov
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
Terry Foster
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Terry Foster
Top achievements
Rank 1
Share this question
or