抱歉这么多的代码,但想彻底..
网格 1 有一个按钮 - 这是它的代码:
name: "custom1", text: "View",
click: function(e) {
$uid = this.dataItem(this.select()).users_id;
$(".title h4").filter(":first").css({
color: "#0070c0",
"text-decoration": "underline",
cursor: "pointer"
});
var offset = $(".grid-box").offset();
var newLeft = offset.left+25;
newLeft = newLeft + "px";
var newTop = offset.top+80;
newTop = newTop + "px";
// Get Profile Info
$.getJSON(
'/data/get_users_data.php',
{ users_id: $uid })
.done( function(tempData) {
$(".echo_users_name").html(tempData.data[0].users_first_name + ' ' + tempData.data[0].users_last_name);
$("#users_email").html("<a href=\"+tempData.data[0].users_email+\">"+tempData.data[0].users_email+"</a>");
$("#users_mobile_phone").html(tempData.data[0].users_mobile_phone);
$('#teamGrid').css("display","none");
$('.grid-box2').css({
display: "block",
position: "absolute",
top: newTop,
left: newLeft,
});
generatePermissionsGrid($uid);
});
},
单击此按钮会隐藏包含它的网格,取消隐藏(css 显示 = 块)一个 div 并生成一个新网格。这是在上面单击后生成的网格(网格#2):
function generatePermissionsGrid(uid) {
$uid = "";
$uid = uid;
$("#permissionsGrid").kendoGrid({
columns: [
{ title: "Access to Application?",
field: "permissions_users_apps_status",
attributes: {
style: "text-align: center; font-size: 14px;"
},
filterable: true,
headerAttributes: {
style: "font-weight: bold; font-size: 14px; width: 100px;"
},
template: function(dataItem) {
if ( dataItem.permissions_users_apps_status == 0 ) {
return "<input type='checkbox' name='permissions_users_apps_status' id='permissions_users_apps_status' value='1' />"
} else if ( dataItem.permissions_users_apps_status == 1 ) {
return "<input type='checkbox' name='permissions_users_apps_status' id='permissions_users_apps_status' value='1' checked />"
}
}
},
{ title: "Application Name",
field: "apps_title",
attributes: {
style: "text-align: center; font-size: 14px;"
},
filterable: true,
headerAttributes: {
style: "font-weight: bold; font-size: 14px; width: 100px;"
}
},
{
command: [
{
name: "custom3", text: "Update",
click: function() {
$pid = this.dataItem(this.select()).permissions_users_apps_id;
/*var $row = $(this);
var enabled = $row.find('#permissions_users_apps_status').attr('checked');*/
// Update App Info
alert($uid + ' - ' + $pid);
$(".k-grid-custom3").off("click");
return;
$.post(
'/data/update_users_permissions.php',
{
users_id: $uid,
apps_id: $pid
}).done( function(data) {
generatePermissionsGrid($uid);
});
}
}/*,
{
name: "custom1", text: "Delete",
click: function(e) {
$pid = this.dataItem(this.select()).permissions_users_apps_id;
// Delete Permissions
$confirmed = confirm("Are you certain you would like to delete\nremove access to this application from this user?");
if ( $confirmed ) {
$.post(
'/data/delete_users_permissions.php',
{
users_id: uid,
apps_id: $pid
})
.done( function(data) {
//
});
}
},
}*/
],
headerAttributes: {
style: "width: 80px;"
},
attributes: {
style: "text-align: center;"
},
title: " "
}
],
dataSource: {
transport: {
read: {
url: "/data/get_users_permissions.php?users_id=" + uid
},
update: {
url: "/data/update_teammate.php",
type: "POST"
},
destroy: {
url: "/data/delete_teammember.php",
type: "POST"
},
create: {
url: "",
type: "POST"
}
},
schema: {
data: "data",
total: function (result) {
result = result.data || result;
return result.length;
},
model: {
id: "permissions_users_apps_id"
}
},
type: "json"
},
pageable: {
refresh: true,
pageSize: 5,
pageSizes: [
5,10,20
]
},
sortable: true,
filterable: true,
autoSync: true,
scrollable: false,
selectable: "row",
reorderable: false
}); // END: teamGrid
} // END: generateGrid function
现在,如果我关闭这个生成的网格(使用 css display = none 隐藏它 - 我已经尝试破坏网格并清除 div 内容 - 没关系)然后我点击上面的按钮(第一个)打开这个再次网格 - 它就像按钮被按下两次一样触发。然后使用相同的按钮再次关闭并重新打开此网格,它会触发 3 次……等等……等等。永远持续下去。
我试过“关闭”点击绑定.. nada。
有人有什么建议吗??
再次感谢,提前...