Hi there
I would like to use a bound combo editor, which provides the possiblity to assign no item at all (setting the property of the record's DataItem to null). The closest thing I've seen to solve this issue is a comment in the online help about an IsNullable property:
Note that the NullText does not specify whether the user is allowed to enter null values into the editor. For that, use the IsNullable property.
However,it appears there is no such property available. Any idea how this should be solved?
Thanks for your advice
Philipp
Another way that i try to achive its in, http://forums.infragistics.com/forums/t/20217.aspx is:
add a button near the DropDownButton to set null XamComboEditor's Value property.
Hi Joe
Thanks for the suggestions! I went with setting IsEditable to true and a NullText string. The other solution didn't quite work: When having a null item in the ItemsSource, an empty line is displayed in the combobox, but selecting it does not assign the null value - this just closes the combobox without setting the field's value at all. IsEditable = true at least allows me to select and manually delete the text. The NullText property however, doesn't work as well - if the field value is null, the cell just stays empty, but I can live with that. Maybe this is related to my binding that contains a DisplayMemberPath. It's not as nice as it could be, but at least it works :-)
Cheers,
ps: This forum really could use a formatting option for code snippets...
<!-- defines the dropdown list to specify unit flags --><Style TargetType="{x:Type igEditors:XamComboEditor}" x:Key="Grid_UnitList"> <Setter Property="IsEditable" Value="True" /> <Setter Property="NullText" Value="(none)" /> <Setter Property="ItemsProvider"> <Setter.Value> <igEditors:ComboBoxItemsProvider DisplayMemberPath="DefaultName" ItemsSource="{Binding Source={StaticResource Data_ProjectController}, Path=CurrentProject.Units}" /> </Setter.Value> </Setter> <Setter Property="DropDownResizeMode" Value="None" /></Style>
The only built in way that I know of to do this would be to set IsEditable to true and specify a NullText string, or leave IsEditable false and have a null item in the dropdown list.
Another approach would be to specify a context menu that does it.
Thanks for the hint. However, this does not solve my issue (the default value of the constraint is to allow null anyway) - I still can't set a null value through the UI as the XamComboEditor limits me to its items (which have been determined using a binding expression). Is there some built-in functionality that allows me to set a cell/editor value to null, or do I have to apply a hack for now?
Cheers
ps: As for users who found the posting searching for a ValueConstraint sample, here's how I applied it:
<!-- defines the dropdown list to specify unit flags --><Style TargetType="{x:Type igEditors:XamComboEditor}" x:Key="Grid_UnitList"> <Setter Property="ItemsProvider"> <Setter.Value> <igEditors:ComboBoxItemsProvider ValuePath="UnitId" DisplayMemberPath="DefaultName" ItemsSource="{Binding Path=CurrentProject.Units}" /> </Setter.Value> </Setter> <Setter Property="ValueConstraint"> <Setter.Value> <igEditors:ValueConstraint Nullable="True" /> </Setter.Value> </Setter> <Setter Property="DropDownResizeMode" Value="None" /></Style>
It seems that the online help is wrong. The ValueEditor base class exposes a ValueConstraint property that exposes a property named 'Nullable'.