2

我克隆到 jsfiddle 的剑道网站上的这个例子工作得很好:http: //jsfiddle.net/destan/xXc82/

但是当我改变这部分时:

schema: {
  model: {
    id: "ProductID",
    fields: {
      ProductID: { editable: false, nullable: true },
      ProductName: { validation: { required: true } },
      UnitPrice: { type: "number", validation: { required: true, min: 1} },
      Discontinued: { type: "boolean" },
      UnitsInStock: { type: "number", validation: { min: 0, required: true } }
    }
  }
}

像这样:(更新小提琴:http: //jsfiddle.net/destan/Wqd4t/1/

schema: {
  data: function(response){
    return response
  }
}

然后在编辑行后单击保存按钮不会更新网格,尽管saveChanges触发了事件。

您可以在开发控制台的选项卡上观察到network,在第一个示例中,在编辑后单击保存按钮会导致向服务器发出请求,而在第二个示例中则没有发出请求。

知道为什么吗?

4

1 回答 1

2

您的代码的问题是您没有定义schema.model.id当您create, update, delete. 所以更正的代码是:

schema: {
  model: {
    id: "ProductID"
  },
  data: function(response){
    return response;
  }
}

小提琴:http://jsfiddle.net/Wqd4t/2/

参考资料:kendo.data.DataSource ,kendo.data.Model

于 2014-02-27T20:09:58.040 回答