【问题标题】:Kendo grid dropdownlist issue剑道网格下拉列表问题
【发布时间】:2018-03-18 10:04:54
【问题描述】:

我在我的剑道网格中的一列上使用了自定义模板。一切都很好,当数据检索时,下拉列表显示正确的值。但是,当我单击编辑命令时,该行变为编辑模式,并且下拉列表不显示其值。只有当我单击下拉列表时,才会显示选中的项目。我想要的是它在编辑模式下显示文本。

点击前编辑

点击编辑后

我的代码:

function customDdlEditor(container, options) {
    $('<input required data-text-field="text" data-value-field="value"  data-bind="value:' + options.field + '"/>')//data-text-field="text" data-value-field="value" data-bind="value:fieldType"
   .appendTo(container)
   .kendoDropDownList({
       autobinds: false,
       dataTextField: "text",
       dataValueField: "value",           
       dataSource: ddl

   });
 }

var ddl = [{ text: "Text", value: "Text" },
        { text: "Date", value: "Date" },
        { text: "Number", value: "Number"}];

var Grid = $("#grid").kendoGrid({
            dataSource: fieldDataSource,                
            columns: [
        ...
        { field: "type", title: "Type", editor: customDdlEditor, template: "#= type #" },
        ...
        ,
            noRecords: true,
        }).data("kendoGrid");

        var fieldDataSource = new kendo.data.DataSource({
            data: gridData,
            pageSize: 50,
            schema: {
                model: {
                    id: "name",
                    fields: {
                        ...,
                        type: { field: "type"},
                        ...
                    }
                }
            }
        });

有人知道怎么解决吗?

【问题讨论】:

  • 缺少一些帮助信息,但我会从这个开始,为什么你的下拉数据源 autoBind 是假的?
  • @DavidLebee 我的错……那行假设是评论行……我把它拿出来,现在它可以工作了……哈哈……顺便说一句,谢谢你指出
  • 当你经过时我发布了一个答案:)

标签: javascript kendo-ui kendo-grid kendo-dropdown


【解决方案1】:

如果你让你的下拉 autoBind: true 应该可以工作。

function customDdlEditor(container, options) {
    $('<input required data-text-field="text" data-value-field="value"  data-bind="value:' + options.field + '"/>')//data-text-field="text" data-value-field="value" data-bind="value:fieldType"
   .appendTo(container)
   .kendoDropDownList({
       autobinds: true, // <-- auto bind true instead
       dataTextField: "text",
       dataValueField: "value",           
       dataSource: ddl

   });
 }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-02
    • 1970-01-01
    • 1970-01-01
    • 2023-03-29
    相关资源
    最近更新 更多