How to use multiselect drop-down in kendo grid?

1 Answer 283 Views
DropDownList Editor Grid MultiSelect
Renu
Top achievements
Rank 1
Iron
Renu asked on 14 Aug 2021, 07:42 AM
im using trying to use a multiselect dropdownlist in my grid.. I'm getting error as Typeerror: cannot read property Text of null.

 

Grid:

@(Html.Kendo().Grid().Name("EmployeesGrid").Columns(columns => {

 columns.Bound(e => e.FirstName).Title("First Name");

 columns.Bound(e => e.LastName).Title("Last Name");

 columns.Bound(e => e.CompanyId).EditorTemplateName("CompaniesList").Title("Company").ClientTemplate("#:CompanyName#");

 columns.Command(command =>{

 command.Edit();

 }

);

}

).ToolBar(toolbar => toolbar.Create()).

Editable(editable => editable.Mode(GridEditMode.InLine)).

DataSource(dataSource => dataSource.Ajax().Events(events => events.Error("error_handler")).

Model(model => model.Id(e => e.Id)).

Create(update => update.Action("CreateEmployee","Home")).

Read(read => read.Action("ReadEmployees","Home")).

Update(update => update.Action("UpdateEmployees","Home"))))

 

After i select the values in the drop-down. im not able to see the values in the field... Need help with this

1 Answer, 1 is accepted

Sort by
0
Petar
Telerik team
answered on 18 Aug 2021, 09:40 AM

Hi Renu,

Attached to my reply, you will find a runnable example that implements the MultiSelect component as an editor of a field inside the Grid. The attached project uses UI for ASP.NET Core but the same as the demonstrated approach is valid in UI for ASP.NET MVC context. 

The column that uses the MultiSelect as an editor template is Employees. The column is defined as follows:

columns.Bound(e => e.Employees).ClientTemplate("#=employeesTemplate(Employees)#");

To display the selected MultiSelect data correctly, we should use the marked in yellow ClientTemplate. The definition of the employeesTemplate function is as follows:

function employeesTemplate(employees) {
    var template = "<ul>";
    for (var i = 0; i < employees.length; i++){
        template += "<li>" + employees[i].Name + "</li>";
    }

    template += "</ul>";
    return template;
}  

I hope the attached example will help you implement what you need in the application you are working on.

Regards,
Petar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
DropDownList Editor Grid MultiSelect
Asked by
Renu
Top achievements
Rank 1
Iron
Answers by
Petar
Telerik team
Share this question
or