网格中特定列的onChange函数

时间:2013-01-31 15:16:01

标签: function grid kendo-ui onchange

好的,所以这就是......我有3列网格:房屋订单,名称和邮政编码

第一栏Premises Order是可编辑的(数字1)。我想要做的是:创建一个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"
                    }
                    }

                    ]
            });

谢谢。

1 个答案:

答案 0 :(得分: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);
},