Using different controls in an editable column

5 posts, 0 answers
  1. Ravish
    Ravish avatar
    7 posts
    Member since:
    Feb 2011

    Posted 30 Nov 2017 Link to this post

    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

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    2483 posts

    Posted 01 Dec 2017 Link to this post

    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.
  3. Ravish
    Ravish avatar
    7 posts
    Member since:
    Feb 2011

    Posted 01 Dec 2017 in reply to Viktor Tachev Link to this post

    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?

  4. Viktor Tachev
    Admin
    Viktor Tachev avatar
    2483 posts

    Posted 05 Dec 2017 Link to this post

    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.
  5. Ravish
    Ravish avatar
    7 posts
    Member since:
    Feb 2011

    Posted 07 Dec 2017 in reply to Viktor Tachev Link to this post

    Thanks for your help. I have found another way.
Back to Top