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

GridViewComboBoxColumn and nulls

1 Answer 93 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David Brenchley
Top achievements
Rank 1
David Brenchley asked on 01 Jul 2010, 10:44 PM
I have set the ItemsSource of my combobox column to a list of custom objects.  This works fine and I am able to update my object with the selected item from the combobox.  The problem is that my users will need to be able to set this column to null, so I add a null to the list of objects.  I can see the null in the list fine, but whenever I select it, the property of the DataMember SalesRep does NOT get set at all.  I have to select a different item in the list.  I've put a break point on the Property set and it isn't firing at all on null.  Is this a bug, or is there a "better" way?

    <DataTemplate DataType="{x:Type lib:Security.UserInfo}">
        <TextBlock>
                <TextBlock.Text>
                    <MultiBinding StringFormat="{}{0}, {1}">
                        <Binding Path="LastName" />
                        <Binding Path="FirstName" />
                    </MultiBinding>
                </TextBlock.Text>
        </TextBlock>
    </DataTemplate>  
...
<telerik1:GridViewComboBoxColumn Name="SalesRepColumn" Header="Sales Rep" DataMemberBinding="{Binding SalesRep, ValidatesOnDataErrors=True,ValidatesOnExceptions=True,UpdateSourceTrigger=PropertyChanged}"/>
...
CollectionViewSource userInfoSource = this.FindResource("userInfoSource"as CollectionViewSource;
var ul = UserInfoList.GetUserInfoList().OrderBy(u => u.LastName).ToList();                        
ul.Insert(0, null);
userInfoSource.Source = ul;
SalesRepColumn.ItemsSource = userInfoSource.View;

...

public UserInfo SalesRep {
get { return GetProperty(SalesRepProperty); }
set { _salesRep = value; }
}


1 Answer, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 06 Jul 2010, 03:33 PM
Hi David Brenchley,

After some research I have found that the problem is in the combo box . RadComboBox  does not support  such setup. The same way behaves the Microsoft ComboBox.

The workarround I may suggest here is to have a special value to substitute the null value in the combo source - something like the "null object pattern".

Sincerely yours,
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
David Brenchley
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Share this question
or