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

Cascading Combo Box Columns

1 Answer 200 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Aydsman
Top achievements
Rank 1
Aydsman asked on 18 Dec 2007, 08:00 AM
Hi,

I'm a relatively new user of the telerik RadControls in Windows Forms and I'm looking to get a piece of functionality working.

Our product requires us to classify a list of items into a "Type / Category / Sub Category" hierarchy.  We would like the items to be displayed in a RadGridView with one column each for "Type", "Category" and "Sub Category".

When a value is selected for the "Type" column the corresponding "Category" cell should populate with the appropriate Category values for that Type value.  This  behavior should be repeated when the "Category" column value is selected.

I have tried creating custom columns as described in this post: "How to add a ProgressBar column ?" however I couldn't seem to get the cell's value to update properly.

I have seen another thread (Dynamic ComboBox) where something similar to what I wish to achieve is described but I am unsure as to the solution.  Wouldn't changing the column's DataSource alter values in all the cells?

Which event is best to handle in order to react after the grid's datasource has been updated?

1 Answer, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 20 Dec 2007, 05:06 PM
Hi Aydsman,

Indeed the dynamic combobox solution is very similar to what you wish to achieve. Unfortunately, it was related to the previous version of RadGridView and this behavior is currently incompatible.

However, I can suggest a different way to implement the behavior you have described. I have prepared a sample application which you could review use in your project. The workaround uses the RadGridView.EditorRequired event. Here's the code you should use in the handler of this event:

private void radGridView1_EditorRequired(object sender, EditorRequiredEventArgs e)  
{             
    string colName = radGridView1.MasterGridViewTemplate.CurrentColumn.UniqueName;            
    if (colName == "col5")  
    {  
        RadComboBoxEditor editor = new RadComboBoxEditor();  
        RadComboBox hostedControl = editor.HostedControl as RadComboBox;  
        hostedControl.BindingContext = radGridView1.BindingContext;   
        GridComboBoxCellElement cell = radGridView1.CurrentCell as GridComboBoxCellElement;  
 
        string itemType = cell.RowInfo.Cells["col4"].Value.ToString();  
        if (itemType == "type1")  
        {  
            hostedControl.DataSource = colors1;  
        }  
        else if (itemType == "type2")  
        {  
            hostedControl.DataSource = colors2;  
        }  
        hostedControl.DisplayMember = "Name";  
        hostedControl.ValueMember = "Name";  
        e.Editor = editor;  
    }             

Note that this approach will only work with the latest version of RadControls. Please, let us know whether this helps you address the issue.

Best wishes,
Georgi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
GridView
Asked by
Aydsman
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Share this question
or