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

Variable Datasources in GridViewComboBoxColumn

3 Answers 122 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 1
Stephen asked on 13 Feb 2013, 05:21 PM
I am trying to accomplish the following functionality using the GridView:

  • I have a database with different fixtures.  Each of these fixtures has a different set of parameters with n options (also stored in the db).
  • The user picks the fixture that they want to customize from a DropDownList.
  • A GridView refreshes based on the DropDownList with the the parameter name in the first column and the options for each parameter in a ComboBox cell in the next column.

I have tried to customize the second column to have different datasources per cell via the following tutorial: 
http://www.telerik.com/support/kb/winforms/gridview/cascading-comboboxes-in-radgridview.aspx

My case is slightly different though in that the value in the left hand column is fixed for the end user but still must have a dynamic drop down set created for it based on a runtime value.  Additionally, there is no event in my execution as there is in the example that would invoke the CellEditorInitialized event and when I attempt to leverage the activeeditor as they have done in that example, I get a null.

If anyone has any insight of how to customize a GridViewComboBoxColumn to have variable datasources or has any other suggestions for a control that may be better fit to my goal, it would be appreciated.  The variable nature of the number of parameters makes it such that I cannot populate the form with a set number of ComboBoxes and set those datasources accordingly. A GridView with a ComboBox column seemed to be the best fit.  

The only other option that I can see is flipping the rows to be columns and having a single row with each column having a separate datasource.  This landscape format is not something that would work well visually on the form though. Any help would be appreciated.

3 Answers, 1 is accepted

Sort by
0
Accepted
Julian Benkov
Telerik team
answered on 18 Feb 2013, 11:54 AM
Hi Stephen,

Thank you for writing.

There is no other way to implement this functionality using RadGridView and GridViewComboBoxColumn. You must use the CellEditorInitialized event handler to change the DataSource and follow other steps to implement the whole behavior.

Feel free to ask if you have any additional questions.

All the best,
Julian Benkov
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
Stephen
Top achievements
Rank 1
answered on 20 Feb 2013, 02:01 PM
Julian,

Is there any other suggestion that you have for implementation other than a RadGridView? Also is there any way to get into the CellEditorInitialized event without manual user input?

Thanks,
Stephen
0
Stephen
Top achievements
Rank 1
answered on 20 Feb 2013, 03:39 PM
In the end, I ended up solving this by populating the dropdrownlist as demonstrated in the example.  What I failed to realize about the example was that the drop down was populating when the cell itself went into edit mode and not at the time that "FruitType" changed.  This was the moment of revelation and one that ultimately solved the problem.  I have some concerns about longer lists and running this code every time a drop down is pressed but until I run into that performance barrier, the solution in the link worked fine.  Thanks.
Tags
GridView
Asked by
Stephen
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Stephen
Top achievements
Rank 1
Share this question
or