1

好的,事情就是这样......我有 3 列的网格:场所顺序、名称和邮政编码

第一列前提顺序是可编辑的(数字)。我想要做的是:创建一个 onChange 函数来保存新插入的数字的值。我知道我需要一个程序,我只想知道如何捕获值(在控制台中),知道我拥有它,然后我将执行该程序。

这是代码

PremisesGrid2 = $("#assignedRoute").kendoGrid({
                dataSource: {
                    type: "application/jsonp",
                    transport: {
                        read:
                                {
                                    url: "http://" + servername + "/uBillingServices/Premise/Premise.svc/GetAllPremisesByRoute",
                                    dataType: "json",
                                    data: function () {
                                        return {

                                            Route_ID: selectedID,
                                            UserName: userName,
                                            WorkStation: workStation

                                        }
                                    }
                                }
                    }, pageSize: 10,
                    serverPaging: true,
                    schema: {
                        model: {
                            fields: {
                                ID: { type: "string", validation: { required: true },     editable: false },
                                PostalCode: { type: "string", validation: { required: true }, editable: false },
                                Latitude: { type: "string", validation: { required: true }, editable: false },
                                Longitude: { type: "string", validation: { required: true }, editable: false },
                                IsMember: { type: "string", validation: { required: true }, editable: false },
                                Name: { type: "string", validation: { required: true }, editable: false },
                                RouteOrderBy: { type: "number", validation: { required: true }, editable: true, nullable: false, format: "{0:n2}" }
                            }
                        },
                        data: function (result) {
                            return result.rows || result;
                        },
                        total: function (result) {
                            var data = this.data(result);
                            return result.totalRows || result.length || 0; ;
                        }
                    }
                },
change: onChange,
                dataBound: function (e) {
                    e.sender.select(e.sender.tbody.find(">tr:first"));
                },
                selectable: "multiple",
                scrollable: true,
                filterable: true,
                editable: true,
                groupable: false,
                pageable: {
                    numeric: true,
                    pageSizes: true,
                    previousNext: false
                },
                sortable: {
                    mode: "single",
                    allowUnsort: false
                },
                height: 400,
                columns: [
                { field: "RouteOrderBy", title: "Premise Order", headerAttributes: {
                    style: "font-size:small; text-align:center"
                }, attributes: { style: "text-align:right" }
                },
                    { field: "PostalCode", title: "Assigned Premises", headerAttributes: {
                        style: "font-size:small; text-align:center"
                    }
                    },
                    { field: "Name", title: "Customer", headerAttributes: {
                        style: "font-size:small; text-align:center"
                    }
                    }

                    ]
            });

谢谢你。

4

1 回答 1

4

而不是使用change事件,你应该使用save. change当存在不在值中的行时发生变化时被触发。

为了显示编辑值、包含编辑值的 HTML 元素和模型中的项目,您可以使用:

save : function (e) {
    console.log("The values entered by the user.", e.values);
    console.log("The jQuery element which is in edit mode.", e.container);
    console.log("The edited model.", e.model);
},
于 2013-02-01T23:33:49.590 回答