打开弹出窗口时我发生了一件奇怪的事情。这里是步骤和相关代码
1)选中行
中的复选框2)点击编辑按钮
编辑按钮的代码是
$(".myEdit").click(function () {
GetSelectedIDs(this.id);
})
function GetSelectedIDs(btn) {
var idsToSend = [];
var grid = $("#Customer-Grid").data("kendoGrid")
var ds = grid.dataSource.view();
for (var i = 0; i < ds.length; i++) {
var row = grid.table.find("tr[data-uid='" + ds[i].uid + "']");
var checkbox = $(row).find(".checkbox");
if (checkbox.is(":checked")) {
idsToSend.push(ds[i].CustomerID);
}
}
switch (btn) {
case "delete": {
if (idsToSend.length > 0) {
Confirmation("delete", idsToSend);
}
}
break;
case "edit": {
if (idsToSend.length > 1) alert("You can only edit one record at a time");
else if (idsToSend.length == 0) alert("Need to select at least one record");
else {
HomeStorage.Keys.StringOfIDs = idsToSend;
HomeStorage.Keys.CustomersID = idsToSend;
CustomerUpdateEditor();
}
}
break;
}
}
以下是CustomerUpdateEditor
function CustomerUpdateEditor() {
$("#showCustomerEdit").append("<div id='window'></div>");
var myWindow = $("#window").kendoWindow({
position: {
top: 100,
left: "30%"
},
width: "40%",
//height: "36%",
title: "Customer",
content: "/Customer/CustomerEditor",
modal: true,
actions: [
"Close"
],
close: function (e) {
$("#window").data("kendoWindow").destroy();
}
}).data("kendoWindow");
myWindow.open();//myWindow.center().open();
HomeStorage.Keys.AddOrEdit = "Edit";
GetStates();
}
和关闭此弹出窗口的按钮是
$("#btnClose").click(function () {
ClearFields();
CloseTheWindow();
GetCustomerGridData();
});
CloseTheWindow函数是
function CloseTheWindow() {
$("#window").data("kendoWindow").destroy();
localStorage.clear();
}
3)现在关闭了弹出窗口并刷新了CustomerGrid,我检查了一个不同的复选框,现在发生的情况是,一旦我检查下一个复选框,也会检查上一个复选框,但它不会感觉它会发生,它不应该发生。
这是Customer-Grid
function LoadCustomerGrid(newData) {
$("#Customer-Grid").kendoGrid({
dataSource: {
data: newData
},
schema: {
model: {
CustomerID: { type: "number" }
}
},
filterable: {
mode: "row"
},
columns: [
{
title: "<input id='checkAll', type='checkbox', class='check-box' />",
template: "<input name='Selected' class='checkbox' type='checkbox'>",
width: "30px"
},
{
field: "CustomerID",
title: "CustomerID",
hidden: true
},
{
field: "LastName",
title: "Last Name",
filterable: {
cell: {
showOperators: false,
operator: "contains"
}
}
},
{
field: "FirstName",
title: "Name",
filterable: {
cell: {
showOperators: false,
operator: "contains"
}
}
},
{
field: "Phone",
title: "Phone",
filterable: {
cell: {
showOperators: false,
operator: "contains"
}
}
},
{
field: "Address",
title: "Address",
filterable: {
cell: {
showOperators: false,
operator: "contains"
}
}
},
{
field: "City",
title: "City",
filterable: {
cell: {
showOperators: false,
operator: "contains"
}
}
},
{
field: "Zip",
title: "Zip",
filterable: {
cell: {
showOperators: false,
operator: "contains"
}
}
}
],
scrollable: true,
sortable: true,
pageable: {
pageSize: 20
},
selectable: "row",
height: $("#Customer-Grid").closest(".col-height-full").height() - 60,
change: function (e) {
// Function call goes here
var detailRow = this.dataItem(this.select());
var optionID = detailRow.get("CustomerID")
}
});
}