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

How to add a (Edit-)Combobox to a Grid (with TagHelper)

3 Answers 609 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lars
Top achievements
Rank 1
Lars asked on 20 Jun 2019, 05:49 PM
Hello,

we want to add a Grid with taghelpers to our razor-pages application.

One Column should be editable (incell) as a Combobox.
Another Column should be should editable as a MultiSelect(Combobox).

Unfortunatelly I could not find any documentation on how to add something like that with taghelpers.

It would be appreciated if you could give me an example on how to do that.

Best regards,

Lars

3 Answers, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 25 Jun 2019, 01:58 PM
Hi Lars,

You can find an example how to create a custom editor for a grid configured via the tag helpers in our Overview article:


Basically, you have to specify the name of the JS handler which initializes the custom editor:

<column field="ProductName" editor="productNameEditor" title="Product Name" width="240" />

And add the handler:

function productNameEditor(container, options) {
    var grid = $('#grid').data('kendoGrid');
    $('<input required name="' + options.field + '"/>')
        .appendTo(container)
        .kendoDropDownList({ // drop down or combobox
            dataSource: {
                data: grid.dataSource.data().map(function (x) {
                    return x.ProductName;
                }).filter(function (value,index, self) {
                    return self.indexOf(value) === index;
                })
            }
        });
}


Regards,
Georgi
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
Uwe
Top achievements
Rank 1
answered on 05 Dec 2019, 01:00 PM

Hi Georgi,

do we have to use JavaScript? Or is it possible to write a Taghelper-Kendo Control in C# and bind this to the editor?

Thx in advance

0
Georgi
Telerik team
answered on 10 Dec 2019, 06:36 AM

Hello Uwe,

The `editor` setting of the column accepts string which is the name of the js handler which creates the editor widget. Thus, you have to use JavaScript initialization. Nevertheless, if you would like to stick to strongly typed API I can suggest you to switch to the Html helpers where you can create server editors.

Regards,
Georgi
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
Lars
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Uwe
Top achievements
Rank 1
Share this question
or