event: {
customRowEvents: {自定义行事件
(record行记录值,rowIndex行索引值,trObj:tr目标,options选择的东西)
click: function (record, rowIndex, trObj, options) {
var RoadBillID = record.RoadBillID;
console.log(RoadBillID);
}
}
}
选中行删除
$("#Delete").click(function () {
var rowIndex = XCXX.getSelectedRowIndex();获取选中行的索引值, 行索引从0开始, 如果没有选择则返回-1
获取单元格值, 根据行索引值及列RoadBillID
if (rowIndex > -1) {
var RoadBillID = XCXX.getColumnValue(rowIndex, “RoadBillID”);
layer.confirm(“确认要删除该内容吗?”, {
icon: 3,
btn: [‘确定’, ‘取消’]
}, function (layerIndex) {
layer.close(layerIndex);关闭提示框
$.post("/ChaoGe/DinD/NoticeDelete", { RoadBillID: RoadBillID }, function (msg) {
if (msg) {
layer.alert(‘删除成功!’, { icon: 1, title: ‘提示’ });
}
else {
layer.alert(‘删除失败!’, { icon: 2, title: ‘提示’ });
}
XCXX.search();
});
});
}
else {
0警告;1成功;2失败;3问号;4锁;5难过表情;6微笑表情
layer.alert(‘请选择需要删除的内容!’, { icon: 0, title: ‘提示’ });
}
});
控制器方法:
public ActionResult NoticeDelete(int RoadBillID)要删除的内容 By 内容ID
{
try
{
根据ID查询要删除的内容
PW_RoadBill dbNoticeTable = (from tbNoticeTable in myModels.PW_RoadBill
where tbNoticeTable.RoadBillID == RoadBillID
select tbNoticeTable).Single();
myModels.PW_RoadBill.Remove(dbNoticeTable);
myModels.SaveChanges();
return Json(true, JsonRequestBehavior.AllowGet);
}
catch (Exception)
{
}
return Json(false, JsonRequestBehavior.AllowGet);
}