我一直在使用JSGrid来表示快速CRUD应用程序。来自MongoDB / Mongoose的数据可以很好地获取数据,但是当我在jsGrid上更新/删除时,它可以正常工作,但是重新加载时不会保存。基本上没有保存到MongoDB中。我尝试了一些事情并浏览了类似的帖子,但似乎无法弄清楚我做错了什么? Javascript中的JSGrid代码
$(function() {
var filter =
$("#jsGrid").jsGrid({
height: "450px",
width: "900px",
filtering: true,
inserting: true,
editing: true,
sorting: true,
paging: true,
autoload: true,
pageSize: 10,
pageButtonCount: 5,
deleteConfirm: "Do you really want to delete client?",
controller: {
loadData: function(filter) {
return $.ajax({
type: "GET",
url: "/projects",
data: filter
});
},
insertProject: function(filter) {
return $.ajax({
type: "POST",
url: "/projects",
data: Project
});
},
updateproject: function(Project) {
return $.ajax({
type: "PUT",
url: "/projects",
data: Project
});
},
deleteproject: function(Project) {
return $.ajax({
type: "DELETE",
url: "/projects",
data: Project
});
}
},
fields: [
{ name: "title", type: "text", width: 150 },
{ name: "location", type: "text", width: 50 },
{ name: "resources", type: "text", width: 200 },
{ type: "control" }
]
}); });
答案 0 :(得分:1)
您的控制器实施了错误的方法。正确的方法名称如下:
...
controller: {
loadData: function(filter) {},
insertItem: function(item) {},
updateItem: function(item) {},
deleteItem: function(item) {}
}
...