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

Custom combobox values in individual cells

7 Answers 290 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Zdenek Svenka
Top achievements
Rank 1
Zdenek Svenka asked on 15 Jul 2008, 01:01 PM
Hello,
how can I display my own combobox values in an unbound RadGridView when editing? The values are not specific to any columns or rows, in my scenario each cell can have completely different combobox values to offer (some can be even edited as free text or as numeric value).

Thanks in advance for your support
ZS

7 Answers, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 18 Jul 2008, 06:05 AM
Hello Zdenek Svenka,

You could set different items for different cells to be displayed in the RadComboBoxEditor by using its Items collection. I have tested this scenario extending the "Unbound mode" example of RadGridView. I have used RadGridView.CellEditorInitialized event to get the current instance of RadComboBoxEditor (when it is just displayed) from ActiveEditor property. Then I changed the data source which the editor is bound to. However, currently it is not possible to enter free text in the GridViewComboBoxColumn (or GridViewLookUpColumn). We intend to add such functionality in the near future.

Here is the sample code I've used:

    private void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)  
    {  
        if (((GridViewDataColumn)radGridView1.CurrentColumn).UniqueName == "column6")  
        {  
            RadComboBoxEditor editor = radGridView1.ActiveEditor as RadComboBoxEditor;                
            if (radGridView1.Rows.IndexOf(radGridView1.CurrentRow as GridViewDataRowInfo) == 5)  
            {     
                editor.DataSource = comboItems2;  
            }  
            else 
            {  
                editor.DataSource = comboItems;  
            }  
        }             
    } 

If you have any additional questions, please don't hesitate to write us.


Sincerely yours,
Georgi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Paul
Top achievements
Rank 1
answered on 21 Jul 2009, 09:36 PM
Hi,
    currently it is not possible to enter free text in the GridViewComboBoxColumn (or GridViewLookUpColumn). We intend to add such functionality in the near future.

Did you ever add this functionality and if so how do enable it?

Thanks
0
Jack
Telerik team
answered on 22 Jul 2009, 10:35 AM
Hi Paul,

This feature is not available in GridViewComboBoxColumn yet. In fact, only a few customers requested this functionality. However, the feature is in our TODO list and it will probably be implemented in one of our upcoming releases. We will increase its priority if more customers request the same. Should you have any other questions, don't hesitate to ask.

Sincerely yours,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Paul
Top achievements
Rank 1
answered on 22 Jul 2009, 10:45 AM
Ok thanks,
                 I got round it by adding an extra item to the combobox that was called ***Add Custom Value*** Then captured the below event
  private void radGridView1_ValueChanging(object sender, ValueChangingEventArgs e)  
        {  
            if (e.NewValue.ToString() == "***Add Custom Value***")  
            {  
                radGridView1.EndEdit();  
                radGridView1.Rows[radGridView1.CurrentCell.RowIndex].Cells[1].Value = Microsoft.VisualBasic.Interaction.InputBox("Please enter your custom value in the box below""Custom Value"null, -1, -1);  
               
            }  
        }  
 
 
    } 

I have now replaced using the input box with my own and getting the Cells index more dynamic. This works a treat and is enough for putting anyone on the right track to achieving this.
0
Jack
Telerik team
answered on 22 Jul 2009, 12:17 PM
Hi Paul,

I am glad to hear that you have found a solution. And thank you for sharing it with the community. If you have other questions, please don't hesitate to write us back.

Kind regards,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Brian
Top achievements
Rank 1
answered on 22 Jul 2009, 06:30 PM
There is no .Datasource property for this editor. It's not showing up in Intellisense and it is not listed as a property in the class definition on your website. How do I get it to work?

Thank You.
0
Jack
Telerik team
answered on 23 Jul 2009, 09:32 AM
Hi Brian,

We did some changes in our editors system in Q2. Now all editors inherit from the BaseGridEditor class which is not a RadElement. You should use the EditorElement property to get the underlying RadElement. Please consider the code sample below:

void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e) 
    if (((GridViewDataColumn)radGridView1.CurrentColumn).UniqueName == "column6"
    { 
        RadComboBoxEditor editor = radGridView1.ActiveEditor as RadComboBoxEditor; 
        RadComboBoxEditorElement editorElement = editor.EditorElement as RadComboBoxEditorElement; 
        if (radGridView1.Rows.IndexOf(radGridView1.CurrentRow as GridViewDataRowInfo) == 5) 
        { 
            editorElement.DataSource = comboItems2; 
        } 
        else 
        { 
            editorElement.DataSource = comboItems; 
        } 
    }              

Find more about editors in this help article. If you have more questions, we will be glad to help.

Best wishes,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Zdenek Svenka
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Paul
Top achievements
Rank 1
Jack
Telerik team
Brian
Top achievements
Rank 1
Share this question
or