kendo网格内的Kendo Combobox编辑无法正常工作

时间:2015-11-16 17:05:33

标签: javascript kendo-ui kendo-mvvm kendo-combobox

我在kendo网格中有一个kendo组合框。我使用MVVM绑定将组合框绑定到列表中的项目。问题是,当我从组合框下拉列表中选择一个项目时一切都很好,但是当我在组合框中手动输入内容时,值不能保存...这是我的网格和组合框代码:

格:

    $("#specificJoinGrid-" + this.gridID).kendoGrid({
        dataSource: this.dataSource,
        autoBind: true,
        toolbar: ["create"],
        sortable: {
            mode: "multiple",
            allowUnsort: true
        },
        columns: [
            { field: "ToField", title: OlapManagerLabels.Field, width: "20%", editor: fieldDropDownEditor.bind(this), template: "#=ToField#" },
            { field: "SpecificOperator", title: OlapManagerLabels.Operator, width: "15%", editor: operatorDropDownEditor.bind(this), template: "#=OlapManagerNamespace.getOperator(SpecificOperator)#" },
            { field: "SpecificValue", title: OlapManagerLabels.Value, width: "30%", editor: valueDropDownEditor.bind(this), template: "#=SpecificValue#" },
            { field: "SecondSpecificValue", title: OlapManagerLabels.SecondValue, width: "30%", editor: secondValDropDownEditor.bind(this), template: "#=SecondSpecificValue#" },
            { command: { name: "x", width: "5%" } }
        ],
        editable: { createAt: "bottom" },
        edit: function(e) {
            var model = e.model; // access edited/newly added model
            // model is observable object, use set method to trigger change event
            model.ID = BINamespace.guid32();
            model.set("id", model.ID);
        },
        selectable: true
    });

的dataSource:

 this.dataSource = new kendo.data.DataSource({
        data: DataSource,
        batch: true,
        schema: {
            model: {
                id: "ID",
                fields: {
                    ToField: { editable: true, required: true },
                    SpecificOperator: { editable: true, required: true, defaultValue: 6 },
                    SpecificValue: { editable: true },
                    SecondSpecificValue: { editable: true },
                    DataSourceID: { defaultValue: this.dataSourceID },
                    ID: {},
                    Type: { defaultValue: 1 },
                    ToTableID: { defaultValue: this.tableID }
                }
            }
        }
    });

组合框:

valueDropDownEditor = function (container, options) {
    var grid = $("#specificJoinGrid-" + this.gridID).data("kendoGrid");
    var row = grid.select();

    if (options.model.SpecificOperator != 1 && options.model.SpecificOperator != 0) {
        $('<input data-text-field="Key" data-value-field="Key" data-bind="value:' + options.field + '"/>')
            .appendTo(container)
            .kendoComboBox({
                autoBind: false,
                dataSource: this.globalsDropDownDS,
                template: "#=Description# (#=Key#)",
                change: value1Changed.bind(this)
            });
    }
    else {
        grid.closeCell(container);
    }
}

1 个答案:

答案 0 :(得分:0)

所以如果有其他人遇到这个问题,我找到了解决方案。一旦我从编辑器中删除了appName属性,组合框就完全按照预期工作了......不知道为什么我花了这么长时间来解决这个问题,但希望它可以帮助一路上的人!