87,972
社区成员
发帖
与我相关
我的任务
分享
<script type="text/javascript">
$('#tt').datagrid({
title: "友情链接列表",
url: '../../../Handler/getData.ashx',
pagination: true,
idField: "ID",
queryParams: { method: "GetLink" },
pageNumber: 1,
onLoadSuccess: function (data) {
if (data == "登录超时!") {
top.window.location = "../../SysAdmin/Login.aspx";
}
},
pageSize: 10,
singleSelect: true,
columns: [[
{ field: 'rowIndex', title: '自动编号', width: 100 },
{ field: 'linkname', title: '链接名', width: 100 },
{ field: 'linkurl', title: '链接URL', width: 100 },
{ field: 'type', title: '链接类型', width: 100 },
{ field: 'linkImg', title: '链接图片', width: 100,
formatter: function (value, rowData, rowIndex) {
if (rowData.linkImg != "") {
return '<a href="../../' + rowData.linkImg + '" target="_blank" style="color:black;text-decoration:none;">点击查看</a>';
}
else {
return "暂未上传";
}
}
}
]],
toolbar: [
{
id: 'btnadd',
text: '添加',
iconCls: 'icon-add',
handler: function () {
window.location = 'AddLink.aspx';
return false;
}
}, {
id: 'btnUpdate',
text: '修改',
iconCls: 'icon-edit',
handler: function () {
var selectItem = $('#tt').datagrid('getSelected');
if (selectItem == null) {
$.messager.alert("提示", "请选择要修改的记录!");
}
else {
window.location = "UpdateLink.aspx?id=" + selectItem.id
}
}
}, {
id: 'btnDelete',
text: '删除',
iconCls: 'icon-cut',
handler: function () {
var selectItem = $('#tt').datagrid('getSelections');
var ID = "";
$.each(selectItem, function (key, value) {
ID += value.id;
});
if (ID == "") {
$.messager.alert("提示", "请选择要删除的记录!");
}
else {
$.messager.confirm("提示", "您确定删除选中的数据吗?", function (r) {
if (r) {
$.post("../../../Handler/getData.ashx", { ID: ID, method: "DeleteLink" }, function (data) {
$.messager.alert("提示", data);
$('#tt').datagrid('reload', {
method: "GetLink"
}); //更新列表
}, "html");
}
});
}
}
}]
});
</script>