我有一个剑道 ui 网格,在更改行事件时,我获取行 ID 并将其传递给另一个加载其他网格的函数。我试图简化操作以找出这样的错误。
HTML 代码
<input type="button" id="load-first" value="Load 108" />
<input type="button" id="load-second" value="Load 92" />
Javascript
$("#load-first").click(function(){
loadEmailGrid(108);
});
$("#load-second").click(function(){
loadEmailGrid(92);
});
function loadEmailGrid(salesRepsId) {
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: "operations/get_emails_sales_reps.php?salesRepsId=" + salesRepsId,
type: "GET"
},
update: {
url: "operations/edit_email.php?salesRepsId=" + salesRepsId,
type: "POST",
complete: function (e) {
$("#email-grid").data("kendoGrid").dataSource.read();
}
},
destroy: {
url: "operations/delete_email.php",
type: "POST",
complete: function (e) {
$("#email-grid").data("kendoGrid").dataSource.read();
}
},
create: {
url: "operations/add_email.php?salesRepsId=" + salesRepsId,
type: "POST",
complete: function (e) {
$("#email-grid").data("kendoGrid").dataSource.read();
}
},
},
schema: {
data: "data",
total: "data.length", //total amount of records
model: {
id: "EmailId",
fields: {
EmailType: {
defaultValue: {
EmailTypeId: 2,
EmailTypeName: "Home"
}
},
EmailText: {
type: "string"
},
IsMainEmail: {
type: "boolean"
},
}
}
},
pageSize: 5,
});
//dataSource.sync();
$("#email-grid").kendoGrid({
dataSource: dataSource,
height: 250,
filterable: true,
sortable: true,
pageable: true,
reorderable: false,
groupable: false,
batch: true,
navigatable: true,
toolbar: ["create", "save", "cancel"],
editable: true,
columns: [{
field: "EmailType",
title: "Type",
editor: EmailTypeDropDownEditor,
template: "#=EmailType.EmailTypeName#",
filterable: {
extra: false,
field: "EmailType.EmailTypeName",
operators: {
string: {
startswith: "Starts with",
eq: "Is equal to",
neq: "Is not equal to"
}
}
}
}, {
field: "EmailText",
title: "Email",
}, {
field: "IsMainEmail",
title: "Main?",
width: 65,
template: function (e) {
if (e.IsMainEmail == true) {
return '<img align="center" src ="images/check-icon.png" />';
} else {
return '';
}
}
// hidden: true
}, {
command: "destroy",
title: " ",
width: 90
},
]
});
}
返回 add_email.php 的示例
[{"EmailId":200}]
例如,如果我使用一个 id 加载网格,我单击加载 108 按钮。添加操作完美运行。但是当我单击并在两个按钮之间混合时。即加载具有不同id 的网格 add 函数多次调用,一次使用先前的id,另一次使用单击的按钮id。更多的按钮之间的混合点击,更多的添加功能被调用。
这是一个显示问题的链接。
请问,我该如何解决这个问题?我尝试了很多没有运气的事情