1
votes

I'm using a editor template to display a combo box for one of the columns in my grid. I want to set the initial text of the combo box from a model property other than the value property. I could normally do this using the Text operator, but because this is inside a grid, I need to load from the data of that particular row. Here's my editor template code:

@(Html.Kendo().ComboBoxFor(Function(x) x) _
.DataTextField("PartNumber") _
.DataValueField("PartID") _
.MinLength(2) _
.AutoBind(False) _
.Text(  "what do I put here"  ) _
.Filter(FilterType.StartsWith) _
.DataSource(Sub(dataSource)
                    dataSource _
                    .Read(Sub(reader)
                                  reader.Action("StartsWith", "Part")
                                  reader.Type(HttpVerbs.Post)
                          End Sub) _
                    .ServerFiltering(True)
            End Sub)
)
1

1 Answers

0
votes

You can call a javascript function which can serve your purpose

function categoryDropDownEditor(container, options) {
        $('<input data-text-field="PartNumber" data-value-field="PartID" data-bind="value:' + options.field + '"/>')
        .appendTo(container)
        .kendoDropDownList({
            autoBind: false,
            dataSource: data //Your Data
            }
        });
    }