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

GridViewComboBoxColumn - Preventing Blank Values

1 Answer 174 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 03 Sep 2010, 07:14 PM
Hi,

I am facing a problem with the GridViewComboBoxColumn.  I have a view set up with a RadGridView using three columns, one of which is a ComboBoxColumn.  The ComboBoxColumn is bound to an ObservableCollection which consists of 9 "Service" items.  The combobox is updating correctly and containing the proper items, and all of the databindings I'm using (using the MVVM model) are working correctly.

The situation is as such.  When I click on the "Click here to add new item" row, and it generates the item to add, the combobox initially has a blank value selected (and it shows blank).  If I click on the combobox, I see all 9 items as options, and there is no blank option to select.  However, if I just click on another cell, the combobox selection stays blank.  If I select one of the specific items in the combobox, then it will update to the item I selected and I will not be able to change it back to a blank value.

The problem I face is this.  I don't want the user to be able to leave that combobox item blank.  I'd prefer, when I initially click the "Click here to add new item" indicator, for the combobox to automatically default to the first item in its list and to display accordingly.  Alternatively, I'd like to configure it to not allow you to add the new row unless a specific item is selected in the combobox.  I haven't been able to find the appropriate properties or methods to call to accomplish there.  Does anyone know how I can set this up?

Thank you,
Jason

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 07 Sep 2010, 12:21 PM
Hi Jason,

In order to set an initial-default value to appear in the ComboBox when adding new item, you may set the constructor of the items so that it defines value for the Property in that particular column. For example:

public Person()
{
    this.countryID = 1;
}

The "CountryID" is the property engaged in the comboBox.
In case you want to implement some Validation logic, you may use the Validating and Validated events of the grid. You can find more information in our online documentation.


Greetings,
Maya
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
Jason
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or