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

Using different controls in an editable column

4 Answers 242 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ravish
Top achievements
Rank 1
Ravish asked on 30 Nov 2017, 06:21 PM

I have a kendoGrid initialized in cshtml. It uses ajax binding.

The grid model looks like { int id, int typeId, string name, string value }.
The grid has 2 columns Name and Value and Value is editable InCell. For now grid works well with using by default usual textbox as editor. I have to improve the grid to have possibility of using different controls in the "value" field depending of the value of "typeId". I tried to use custom EditorTemplate for that but I cannot find a way to pass typeId to the template (the column is bound to "value"). Is it possible to pass there an extra parameter from the grid model or reach it out from the template somehow?

Regards, Alexey

Here is the link to the same post on Stackoverflow:

https://stackoverflow.com/questions/47577527/using-different-controls-in-a-editable-column

4 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 01 Dec 2017, 03:22 PM
Hello Alexey,

Have in mind that using different editors in the same column is not a built-in feature. Furthermore, such functionality is not recommended. This implies that the underlying data will be stored as a string. As a result an extensive custom logic will be required for validating and reading the data and parsing it to the correct type. 

In order to take advantage of the built-in features of the components I will strongly recommend modifying the data in a way that each different data type is stored in a separate field. This way, the editing, filtering, sorting, etc. features will work out of the box with no need of complex custom logic.


Regards,
Viktor Tachev
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Ravish
Top achievements
Rank 1
answered on 01 Dec 2017, 05:59 PM

Thanks for your answer,

But I still need the solution since I have such requirements. I am aware about  editing, filtering, sorting and etc. features but I have another solution for them. All that I need to reach the grid model out of editor template or pass an additional parameter there. Otherwise I will be forced to override grid events to create the controls 'on-fly' that would be a worse solution in my opinion.

Do you have any ideas how it could be done?

0
Viktor Tachev
Telerik team
answered on 05 Dec 2017, 02:01 PM
Hi,

Using different templates for the same field is not a supported feature. Implementing such behavior would require additional custom logic. 

Since in that scenario the field will be a string the Grid will generate a TextBox as editor by default. When editing you can handle the beforeEdit event and instantiate the new editor manually based on specific conditions.

Have in mind that implementing such functionality is not recommended and can lead to issues down the road.

Regards,
Viktor Tachev
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Ravish
Top achievements
Rank 1
answered on 07 Dec 2017, 04:23 PM
Thanks for your help. I have found another way.
Tags
Grid
Asked by
Ravish
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Ravish
Top achievements
Rank 1
Share this question
or