Javascript 剑道UI网格保存在单元格模糊上
当您按enter键或移出单元格(模糊)时,我试图让我的网格保存更改,而不必使用网格工具栏中的保存按钮 我很难让它正常工作,我的PHP/SQL工作得很好,所以我确信这是网格出了问题 这是我的密码:Javascript 剑道UI网格保存在单元格模糊上,javascript,jquery,json,gridview,kendo-ui,Javascript,Jquery,Json,Gridview,Kendo Ui,当您按enter键或移出单元格(模糊)时,我试图让我的网格保存更改,而不必使用网格工具栏中的保存按钮 我很难让它正常工作,我的PHP/SQL工作得很好,所以我确信这是网格出了问题 这是我的密码: $("#grid").kendoGrid({ dataSource: { transport: { read: WEBROOT+"admin/fetch-toppers", update: { url: WEBROOT+"admin/upd
$("#grid").kendoGrid({
dataSource: {
transport: {
read: WEBROOT+"admin/fetch-toppers",
update: {
url: WEBROOT+"admin/update-topper",
type: "POST"
}
},
error: function(e)
{
alert(e.responseText);
},
schema: {
data: "data",
model: {
id: 'id',
fields: {
"id": {nullable: true},
"Date": {editable: false},
"name": {editable: false},
"price": {editable: true}
}
}
}
},
columns: [{field: "Date", width: 105}, {field: "name", title: "Topper"}, {field: "price", title: "Price", width: 125}],
height: 550,
filterable: true,
sortable: true,
pageable: true,
editable: true,
navigatable: true,
edit: function()
{
//this.saveChanges()
}
});
我尝试过很多事情和不同的事件,但都没有效果
如何使其在模糊上保存单元格值?您可以尝试使用数据源的事件来执行数据源的方法
$("#grid").kendoGrid({
dataSource: {
transport: {
read: WEBROOT+"admin/fetch-toppers",
update: {
url: WEBROOT+"admin/update-topper",
type: "POST"
}
},
change:function(){this.sync()},
error: function(e)
{
alert(e.responseText);
},
schema: {
data: "data",
model: {
id: 'id',
fields: {
"id": {nullable: true},
"Date": {editable: false},
"name": {editable: false},
"price": {editable: true}
}
}
}
},
columns: [{field: "Date", width: 105}, {field: "name", title: "Topper"}, {field: "price", title: "Price", width: 125}],
height: 550,
filterable: true,
sortable: true,
pageable: true,
editable: true,
navigatable: true,
edit: function()
{
//this.saveChanges()
}
});
在数据源中添加:
change: function (e) {
if (e.action == "itemchange") {
this.sync();
}
},
它应该是这样的:
dataSource: {
transport: {
read: WEBROOT+"admin/fetch-toppers",
update: {
url: WEBROOT+"admin/update-topper",
type: "POST"
}
},
error: function(e)
{
alert(e.responseText);
},
change: function (e) {
if (e.action == "itemchange") {
this.sync();
}
},
schema: {
data: "data",
model: {
id: 'id',
fields: {
"id": {nullable: true},
"Date": {editable: false},
"name": {editable: false},
"price": {editable: true}
}
}
}
},您也可以从网格中调用数据源同步,如下所示(请确保按照本文中的Telerik使用setTimeout)
有一种更简单的方法来实现这一点:在数据源上将autoSync设置为true:我如何将我所拥有的内容放入上下文中?我如何更改代码以实现您的建议?我已经尝试了所有的方法,但仍然不起作用,但是它可以通过“保存更改”按钮正常工作,但这不是我想要的。我已经更新了我的帖子,检查了数据源错误函数上方的行。我尝试了它,但现在我得到了一个永远不会消失的加载程序。我得到的对象[对象]没有“同步”方法非常好!非常感谢。剑道论坛中有许多帖子需要看到这一点!
save: function () {
setTimeout(function() {
yourDatasource.sync();
}
}