This is a migrated thread and some comments may be shown as answers.
GridView ComboBox and create a new Row
1 Answer 17 Views
This is a migrated thread and some comments may be shown as answers.
IBST
Top achievements
Rank 1
IBST asked on 24 Apr 2011, 04:44 PM
Hello,

I want to use the GridView to make the user enter some data. The cenario is this:

When the user open the window the grid will be empty with a blank row. The first row has a combo box and the rest of the column are read-only. The user choose what he want in the combo (from the first column) and the system should fill the data (from the selected item in the combo) in all columns.

The system should notice that there aren't any empty row and create one.

What I have until now? I can create the new row when the form open, I can bind the combobox with the list that I want.

What I need to know? How can get the selected item in the combo? How can we have or check for a "New Row" in the grid?

Can you make a little example of this usage?

regards
Paulo Aboim Pinto
Odivelas - Portugal

1 Answer, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 25 Apr 2011, 09:21 AM
Hi Paulo,

There are two ways to implement such behavior .

The first one is to place your logic in the business object you are binding to and the second - to rely on the UI to do the job.

For example lets say our RadGridView is bound to a Location object which has two fields - Continent and Country.

The user selects a continent , and the we need to auto populate the Country with a value matching the continent .
What we can do :
1. Approach one : - Within the setter of the Continent Property we can set the Country - e.g. when the user changes the continent , country is auto-populated. This will require the object to implement the INotifyPropertyChanged interface  so that RadGridView will sense any changes in the values and update the UI automatically.

2. Approach two - listen for the selection changed event of the combo and populate the other fields when  needed .

Such approach is demonstrated in this blogpost . There is a detailed explanation and a source code available on how to handle the selection changed events of the combo .

Hope that helps.

Kind regards,
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
Asked by
IBST
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Share this question
or