添加新记录时,Kendo Grid初始化编辑器列(下拉列表)

时间:2014-05-13 15:13:12

标签: kendo-ui kendo-grid

我有一个剑道网格。而我正在创建一个"添加新记录"它显示了一行可编辑,这很好。但在这种情况下,我使用了两个编辑模板用于两个单独的列。

点击"添加新记录"可编辑的行编辑器(下拉列表)空白。

我想使用初始值初始化编辑器(下拉列)列(如果可能,下拉列表中的第一项)

为了更好地理解下面是网格代码。还有下拉编辑器代码

var grid = $("#grid").kendoGrid({
        dataSource: {

            transport: {
                read: {
                    url: "GetTaskAllocationGrid",
                    type: "POST",
                    contentType: "application/json",
                    dataType: "json"
                },

                update: {
                    url: "UpdateTaskAllocationData",
                    contentType: "application/json",
                    type: "POST",
                    dataType: "json",
                    complete: function (data) {

                        var result = jQuery.parseJSON(data.responseText);

                        if (result.State == true)
                        {
                            toastr.success(result.Description);
                            $("#grid").data("kendoGrid").dataSource.read();
                        }
                        else
                        {
                            toastr.error(result.Description);
                        }
                        $("#grid").data("kendoGrid").dataSource.read();
                    }
                },
                destroy: {
                    url: "DestroyTaskAllocation",
                    contentType: "application/json",
                    type: "POST",
                    dataType: "json",
                    complete: function (data) {
                        var result = jQuery.parseJSON(data.responseText);

                        if (result.State == true) {
                            toastr.success(result.Description);
                        }
                        else {
                            toastr.error(result.Description);
                        }
                        $("#grid").data("kendoGrid").dataSource.read();
                    }
                },
                create: {
                    url: "CreateTaskAllocation",
                    contentType: "application/json",
                    type: "POST",
                    dataType: "json",
                    complete: function (data) {
                        var result = jQuery.parseJSON(data.responseText);

                        if (result.State == true) {
                            toastr.success(result.Description);
                        }
                        else {
                            toastr.error(result.Description);
                        }
                        $("#grid").data("kendoGrid").dataSource.read();
                    }
                },
                parameterMap: function (data, operation) {
                    if (operation != "read") {
                        return kendo.stringify(data.models);
                    }

                }
            },

            serverPaging: false,
            pageSize: 10,
            batch: true,

            schema: {
                model: {
                    id: "IDChargedTaskCatagory",
                    fields: {
                        IDChargedTaskCatagory: { editable: false },
                        Task: { editable: true },
                        ChargeRate: { editable: true },
                        TaskReportingMetrices: { editable: true }
                    }
                },
                errors: "Errors"
            },

            error: function (e) {
                alert(e.errors + "grid");
            }
        },
        editable:
            {
                mode: "inline",
                createAt: "bottom"
            },
        pageable: {
            refresh: true,
            pageSizes: true
        },
        toolbar: [
        {
            name: "create",
            text: "Add new record"
        }
        ],
        sortable: true,
        autoBind: false,
        create:function(e)
        {
            alert("create");
        },

        edit: function (e) {

        },
        update: function (e) {
        },
        columns:
        [
            { field: "IDChargedTaskCatagory", width: 50, hidden: true, title: "ID" },
            { field: "Task", width: 100, title: "Task Name" },
            { field: "ChargeRate", width: 100, title: "Charge Rate", editor: ChargeRateDropDownEditor },
            { field: "TaskReportingMetrices", width: 100, title: "Task Metric", editor: TaskMetricsDropDownEditor },
            { command: ["edit", "destroy"], title: "Action", width: "175px" }
        ]
    }).data("kendoGrid");

    $("#grid").data("kendoGrid").dataSource.read();

    $(".k-grid-add", grid.element).on("click", function (e) {
        var dataSource = grid.dataSource;
        var total = dataSource.data().length;
        dataSource.insert(total, {});
        dataSource.page(dataSource.totalPages());
        grid.editRow(grid.tbody.children().last());
    });

下拉编辑器列位于

之下
function ChargeRateDropDownEditor(container, options) {
           $('<input required data-text-field="Name" data-value-field="Name" data-bind="value:' + options.field + '"/>')
               .appendTo(container)
               .kendoDropDownList({
                   autoBind: false,
                   dataSource: {
                       transport: {
                           read: {
                               url: "GetChargeRateDropDownData",
                               type: "POST",
                               contentType: "application/json",
                               dataType: "json"
                           }
                       }
                   },
                   dataTextField: "Name",
                   dataValueField: "Name"
               });
       }
It does'nt Update up to when I dont feel all the column.

我想要什么

1.点击&#34;添加新记录&#34;选定的编辑行编辑器(下拉)使用默认/第一项从下拉列表初始化。 2.当我感觉不到所有栏目时,它不会更新。有什么办法吗?

0 个答案:

没有答案