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

Custom Column types?

7 Answers 382 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tony
Top achievements
Rank 1
Tony asked on 14 Dec 2007, 03:29 PM
Hi,

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

Sort by
0
Georgi
Telerik team
answered on 18 Dec 2007, 04:58 PM
Hi Tony,

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
0
Tony
Top achievements
Rank 1
answered on 18 Dec 2007, 05:20 PM
Hi,

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
0
Georgi
Telerik team
answered on 21 Dec 2007, 08:59 AM

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,

Georgi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Mohammed
Top achievements
Rank 1
answered on 17 Oct 2018, 01:38 PM
Kindly, i have problem that value of custom column is removed or reset while adding new row in RadGridView
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.
0
Dimitar
Telerik team
answered on 18 Oct 2018, 08:25 AM
Hi Mohammed,

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
Get quickly onboard and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Mohammed
Top achievements
Rank 1
answered on 18 Oct 2018, 08:37 AM

Hi Dimitar,

Thank you for your reply and Help.

kindly, implementing SelectionChanged of my Custom Control   is useful and fix my problem.

0
noha
Top achievements
Rank 1
answered on 14 Jan 2019, 12:22 PM

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?

 

 

 

Tags
GridView
Asked by
Tony
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Tony
Top achievements
Rank 1
Mohammed
Top achievements
Rank 1
Dimitar
Telerik team
noha
Top achievements
Rank 1
Share this question
or