一直試圖在Kendo網格上進行更新,並遇到問題。Kendo UI Grid - 更新不會持續
我使用Rails作爲後端,當我做了更新,服務器似乎表明一切正常:
Started PUT "/" for 127.0.0.1 at 2012-02-12 17:28:19 -0600
Processing by HomeController#index as
Parameters: {"models"=>"[{\"created_at\":\"2012-02-08T17:34:50Z\",
\"first_name\":\"Milla\",\"id\":2,\"last_name\":\"sfasfsdf\",\"password\":\"\",
\"updated_at\":\"2012-02-08T17:34:50Z\",\"user_name\"
:\"\"}]"}
Rendered home/index.html.erb within layouts/application (3.0ms)
Completed 200 OK in 89ms (Views: 88.0ms | ActiveRecord: 0.0ms)
然而,當我刷新視圖,一切都沒有改變。當我檢查數據庫時,當然也沒有發生變化。
我通過文檔跑到這裏瞭解如何在網格中做編輯:http://demos.kendoui.com/web/grid/editing.html
而且我看了關於如何設置網格使用Rails伯克奧朗視頻:http://www.youtube.com/watch?v=FhHMOjN0Bjc&context=C3f358ceADOEgsToPDskKlwC22A9IkOjYnQhYyY9HI
必須有我沒有做對的事情,但我只是沒有看到它。
這裏是我的代碼,與劍道東西的作品:
var User = kendo.data.Model.define({
id: "id",
fields: {
first_name: { validation: { required: true } },
last_name: { validation: { required: true } }
}
});
var UsersData = new kendo.data.DataSource({
transport: {
read: {
url: "/users.json"
},
create: {
url: "https://stackoverflow.com/users/create.json",
type: "POST"
},
update: {
type: "PUT"
},
destroy: {
type: "DELETE"
},
parameterMap: function(options, operation) {
if (operation !== "read" && options.models) {
return {models: kendo.stringify(options.models)};
}
}
},
batch: true,
pageSize: 5,
schema: {
model: User
}
});
$("#users-grid").kendoGrid({
dataSource: UsersData,
navigatable: true,
editable: true,
selectable: true,
pageable: true,
sortable: true,
toolbar: ["create", "save", "cancel"],
columns: [
{
field: "first_name",
title: "First Name"
},
{
field: "last_name",
title: "Last Name"
},
]
});
你如何設置處理後端的PUT?由於您正在批量發送數據,因此您必須以不同的方式處理它。也許檢查這個帖子? http://stackoverflow.com/questions/1507011/bulk-update-objects-using-form-in-rails – 2012-02-13 20:30:58