Telerik Grid arbitrary fields

Viewed 43

I need to be albe to edit multiple values in a grid

Say

"Type" is a combo "Size" is a float "Name" is a string

I need "Type", "Size", "Name" in the first column; and in the second I need a dropdown (Type), then a numeric editor (Size) and finally a text editor for the "Name".

I try to implement something similar to that

enter image description here

having heterogenous data in a column, so, impossible to have a template for the elements of the column

1 Answers

It is enough to supply editors for cells that correspond to the field names that you have. For instance, if you have "Type", the Name of the DropDownList has to be "Type".

 @(Html.Kendo().DropDownList()
    .Name("Type")
    // other options
)

You could specify all of the needed editors in separate cshtml files inside the EditorTemplates folder and reference them via the EditorTemplateName option of the column:

columns.Bound(e => e.FieldName).EditorTemplateName("<<editor name goes here>>");

The grid will take care of the binding part. For the complex ones, you might have to specify "data-bind" attributes.

Related