I have a weird thing going on when opening a popup window..Here are the steps and the relative code
1) Check a checkbox from the row
2) Click on Edit button
The code for the edit button is
$(".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;
}
}
Here is the 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();
}
and the button that closes this popup is
$("#btnClose").click(function () {
ClearFields();
CloseTheWindow();
GetCustomerGridData();
});
The CloseTheWindow function is
function CloseTheWindow() {
$("#window").data("kendoWindow").destroy();
localStorage.clear();
}
3) Now that the popup is closed and the CustomerGrid is refreshed, I check a different checkbox, well now what happens is that once I check the next checkbox the previous checkbox is checked as well and it doesn't make sense that it would happen, it shouldn't happen.
This is the 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")
}
});
}