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

Create controls run time base on data in grid

3 Answers 49 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Prashant
Top achievements
Rank 1
Prashant asked on 06 Dec 2018, 09:55 PM

Hi-

I'm trying to create master-details grid with Add, edit and delete functionality in both, In details grid i have two columns "Name" (Drop Down) and "Value" (Run time Control). When i will select name than value control should get created in value column as per type mention in Data. So for example if select XXX name and it's type is Date then Date control should be created in value column, if i select other name "ZZZZ" and it's type is list then drop down control should be created in value column at run time. I have 5 types as of now to create run time value control (String, date, Numeric, currency and Drop Down). Along with this i should be able to add, edit and delete master/detail rows.

Any help with code sample in achieving this is deeply appreciated. Below my Master/Detail data where Attributes will get bind to detail section and type will let know which control to create run time.

var Data = [
    {
        "LR_Name": 'Long Term',
        "LRVR_Opt_To_Decline": 'Y',
        "LRVR_Required": 'Y',
        "LPVR_Active": 'Y',
        "Attributes": {
            "Attribute": [
                {
                    "Name": "ABR Duration",
                    "Value": "2",
                    "Type": 'list'

                },
                {
                    
                    "Name": "EBR Duration",
                    "Value": "2",
                    "Type": 'Number'
                    
                }
            ]

        }
    },
    {
        "LR_Rider_Name": 'LTCR',
        "LRVR_Opt_To_Decline": 'Y',
        "LRVR_Required": 'N',
        "LPVR_Active": 'N',
        "Attributes": {
            "Attribute": [
                {
                    "Name": "LTCR Supp Date",
                    "Value": "01-01-2018",
                    "Type": 'date'

                },
                {
                    
                    "Name": "LTCR Supp Amount",
                    "Value": "2500",
                    "Type": 'Currency'
                }
            ]

        }
    },
    {
        "LR_Rider_Name": 'Extended Benefit',
        "LRVR_Opt_To_Decline": 'Y',
        "LRVR_Required": 'N',
        "LPVR_Active": 'N',
        "Attributes": {
            "Attribute": [
                {
                   
                    "Name": "Benefit Type",
                    "Value": "5% Simple",
                    "Type": 'String'

                },
                {
                    
                    "Name": "Benefit",
                    "Value": "10% Simple",
                    "Type": 'String'
                }
            ]

        }
    }
];

3 Answers, 1 is accepted

Sort by
0
Alex Hajigeorgieva
Telerik team
answered on 10 Dec 2018, 04:23 PM
Hello, Prashant,

It is possible to achieve the desired behaviour in the Kendo UI Grid by declaring a custom columns editor function:

https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/configuration/columns.editor

We have an article with a runnable example that you may follow at:

https://docs.telerik.com/kendo-ui/knowledge-base/grid-use-dynamic-editor

Should you face any difficulties, please feel free to get back to me.

Kind Regards,
Alex Hajigeorgieva
Progress Telerik
Get quickly onboarded 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
Prashant
Top achievements
Rank 1
answered on 11 Dec 2018, 11:49 PM

Hi Alex- Thanks! for reply, i got the knowledge base article on this as you mention in your response and one as (https://docs.telerik.com/kendo-ui/knowledge-base/grid-different-editor-based-on-column-value). But this article was limited to read only demo of custom editor. I was looking for some thing with parent/child grid which can add edit and delete on custom editor. I'm trying to create this grid but grid is behaving unexpected collapsing behaviors along with not functioning properly on newly added row. Also i'm struggling for approach to go  whether inline editing with ADD, (EDIT and DELETE button for each row) or Batch Editing with only ADD and (Delete button for each row) will make more sense here.

In my post i have mention the Data for which i'm trying to build parent/child grid. In Data, Attributes gets bind to child grid and where i have custom editor depending on type. My parent grid does not have custom editor.

Any sample on this will be deeply appreciated.

Thanks!

0
Alex Hajigeorgieva
Telerik team
answered on 12 Dec 2018, 04:25 PM
Hello, Prashant,

The article demonstrates how to dynamically create a custom editor and you can verify that it delivers what it should by clicking on the editor column:



Kendo UI does not distinguish whether it is a child grid or a master grid so this approach can be used in any editable grid.

As far as the collapsing of the details, this is expected because they are collapsed by default. We have another demo which illustrates how to overcome this behaviour here:

https://docs.telerik.com/kendo-ui/controls/data-management/grid/how-to/Editing/edit-master-row-data-in-detail-template

Kind Regards,
Alex Hajigeorgieva
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Prashant
Top achievements
Rank 1
Answers by
Alex Hajigeorgieva
Telerik team
Prashant
Top achievements
Rank 1
Share this question
or