【发布时间】:2018-07-29 14:39:50
【问题描述】:
我在 kendogrid 中使用 kendoDropDownList。 现在,当我通过调用
编辑该行时grid.editRow(tr);
函数,为编辑打开行。
它在编辑模式下显示 kendoDropDownList 但无法保留原始值。
我尝试使用数据绑定事件来选择原始值
let input = $('<input name= "' + options.field + '" required = "required"/>');
input.attr('id', options.field);
input.attr('data-text-field', 'Name');
input.attr('data-value-field', 'Name');
input.attr('data-bind', 'value:' + options.field);
input.width(container.width());
input.appendTo(container);
input.kendoDropDownList({
autoBind: false,
dataTextField: 'Name',
dataValueField: 'Name',
optionLabel: 'Select',
dataBound: (e) => {
$('#' + options.field).data('kendoDropDownList').value(options.model.dropDownValue) ;
},
dataSource: {
data: this.list,
schema: {
data: 'value'
}
}
});
如果我不这样做,只需调用 validate
$('#grid').kendoValidator().data('kendoValidator').validate();
它显示了 kendoDropDownList 的验证消息。 因为当我在编辑模式下打开时,我正在设置下拉列表的值。那么为什么它显示验证消息,即使它的值是在数据绑定事件中设置的。
我在这里做错了吗?
【问题讨论】:
标签: javascript kendo-ui kendo-grid kendo-dropdown