Is it possible to have custom column types in your grid?
I need to a column that in edit mode is a drop down list of values, with each entry being color coded. I need to then convert the selected value to an enum
I made a custom column based on your GridViewComboBoxColumn, which is displaying the list of values okay, but when I select one, I can't seem to cast it to an enum
And I can't change the colors because I don't seem to have access to the combo box itself. It looks like I would have if I could write an editor based on RadComboBoxEditor, but then I can't find a way to associate the editor with the column?
any help/suggestions much appreciated.
thanks
7 Answers, 1 is accepted
Thank you for writing.
Yes, it is possible to have custom column as you inherit GridViewDataColumn or its descendant class. However, in your scenario (if I have understood it correctly) I would suggest using the current GridViewComboBoxColumn. To illustrate a similar implementation, I am attaching a sample application.
Please, review it and if you need further assistance, please write us again with additional details about your project.
Kind regards,
Georgi
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
As per my original post, I have based a control on GridViewComboBoxColumn as you suggest.
This however does not give me access to the actual combo box used.
There are several issues:
1. When a value is selected in the combo, I need to cast it to the underlying enum type. I tried capturing the Validating event and changing the value from a string representation to the enum representation, but that is clearly ignored later as I still get a casting error.
2. The current enum value from the underlying object in the grid is not showing up as selected when I go into edit mode.
3. The color issue - i want the items in the combo to be different colors. For a "regular" combo, I would override the paint method, but in a GridViewComboBox column, I have no access to the actual combo box used, so I have no way to override the Paint method.
The example you kindly sent me was merely using a regular GridViewComboBoxColumn and populating it with some color names from an array. You did not create a custom control, or bind to an actual enum.
thanks
Hi Tony,
I am not sure what exactly are the requirements of your scenario. In spite of this, I have tried with an enumeration and it works correctly.
I have replaced the colors array with the following:
comboCol.DataSource = Enum.GetValues(typeof(System.IO.FileAccess));
I have also removed setting DisplayMember and ValueMember properties. However if you continue to experience problems, it would be better to send us a sample application that demonstrates your scenario.
As to the color issue, you could access the RadComboBoxEditor as you attach to the RadGridView.CellEditorInitialized event. In the handler, you can get the value of the RadGridView.EditingElement property. However, I am afraid that setting different colors of the items in its dropdown window is not possible. Perhaps this could be done if you inherit RadComboBoxEditor and fill its Items collection with runtime created items instead of binding to an enumeration.
If you have additional questions, please contact us.
Kind regards,
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
i create custom control "AccountDropDownTree" that contains DropDownBox and TreeView
to view financial account tree.
then i added custom control to AccountCellElement as in attached code picture "Custom Cell element".
then set cell type of custom column " GridViewAccountColumn" to AccountCellElement as in attached code picture "Custom Column"
the problem is that while enter data or adding new row , i select account from custom column gridviewaccountcolumn,but once i pressed Tab or moved to next cell the value of Custom column gridviewaccountcolumn is removed or reset to default.
even cellvalue for that column in code behind is null.
please, is there any advice to fix this issue.
In the custom cell element class, you need to subscribe to the SelectedNodeChanged or other three view event and update the cell value.
I would recommend you to post a ticket and attach your implementation so we can give you the code for this.
I hope this will be useful. Let me know if you have additional questions.
Regards,
Dimitar
Progress Telerik
Hi Dimitar,
Thank you for your reply and Help.
kindly, implementing SelectionChanged of my Custom Control is useful and fix my problem.
Kindly I can not control tab of custom control at Gridview.
I want to use tab key between grid cell.
Could you help me please?