Kendo UI JS网格编辑单元格不起作用,不会出错

时间:2015-05-12 09:46:32

标签: javascript kendo-ui kendo-grid

当我按下任何一个单元格时,单元格会聚焦但我无法在该字段中键入任何内容。我也没有任何控制台错误。这是代码:

    $(document).ready(function () {
datasource = new kendo.data.DataSource({
    transport: {
        read: {
            url: '/DiscountPromotion/Get',
            dataType: "json",
        },
        update: {
            url: '/DiscountPromotion/Update',
            dataType: "json",
            type: "POST",
            contentType: "application/json"
        },
        destroy: {
            url: '/DiscountPromotion/Delete',
            dataType: "json",
            type: "POST",
            contentType: "application/json"
        },
        create: {
            url: '/DiscountPromotion/Add',
            dataType: "json",
            type: "POST",
            contentType: "application/json"
        },
        parameterMap: function(options, operation) {
            if (operation !== "read") {
                return JSON.stringify({ discountPromotionDto: options });
            }
        },

    },
    pageSize: 10,
    schema: {
        model: {
            id: "Id",
            fields: {
                Id: { type: "number" },
                Code: { type: "string" },
                StartDate: { type: "date" },
                EndDate: { type: "date" },
                MinimumCost: { type: "number" },
                MaximumCost: { type: "number" },
                Quantity: { type: "number" },
                CustomerId: { type: "number" },
                CountryCode: { type: "string" },
                Discount: { type: "number" },
                ModelName: { type: "string" }
            }
        }
    }
});
$("#discountpromotiongrid").kendoGrid({
    dataSource: datasource,
    batch: true,
    toolbar: ["create", "save", "cancel"],
    height: 400,
    navigatable: true,
    pageable: {
        refresh: true,
        pageSizes: true,
        buttonCount: 5
    },
    columns: [
    {
        field: "ModelName",
        title: "ModelName",
        editor: modelNameDropDown,
        template: "#=ModelName#",
        width: 150
    },
    {
        field: "Code",
        title: "PromotionCode",
        width: 150
    },
    {
        field: "StartDate",
        title: "StartDate",
        template: '#= kendo.toString(StartDate,"yyyy-MM-dd") #',
        width: 120
    },
    {
        field: "EndDate",
        title: "EndDate",
        template: '#= kendo.toString(EndDate,"yyyy-MM-dd") #',
        format: "{0:yyyy-MM-dd}",
        parseFormats: ["yyyy-MM-dd"],
        width: 120
    },
    {
        field: "MinimumCost",
        title: "MinCost",
        width: 100
    },
    {
        field: "MaximumCost",
        title: "MaxCost",
        width: 100
    },
    {
        field: "Quantity",
        title: "Quantity",
        width: 80
    },
    {
        field: "CustomerId",
        title: "CustomerId",
        width: 80
    },
    {
        field: "CountryCode",
        title: "CountryCode",
        width: 40
    },
    {
        field: "Discount",
        title: "Discount",
        width: 40
    },
    {
        command: "destroy",
        title: " ",
        width: 120
    }],
    editable: true
});



function modelNameDropDown(container, options) {
    $('<input required data-text-field="ModelName" data-value-field="ModelName" data-bind="value:' + options.field + '"/>')
        .appendTo(container)
        .kendoDropDownList({
            autoBind: false,
            optionLabel: "Select model...",
            dataSource: {
                serverFiltering: true,
                transport: {
                    read: {
                        url: '/DiscountPromotion/GetModelNamesByCustomerId',
                        dataType: "json",
                        type: "POST",
                        contentType: "application/json"
                    }
                }
            }
        });
}

enter image description here

请帮忙!我不知道什么是错的。

这是我的网格图像,当我按下一个单元格时。标记永远不会出现在单元格中,因此我无法输入任何内容。这发生在他们所有人身上!

1 个答案:

答案 0 :(得分:0)

You need to add an edit command to your columns.

Error: TypeError: undefined is not a function
    at
  at Object.exports.run (C:\Users\AppData\Roaming\npm\node_modules\protractor\lib\frameworks\jasmine.js:6
相关问题