我有一个jqGrid和SubGrid,当SubGrid为null时,我希望取消绑定事件展开行和图标展开行数据。当我将一行从其他网格拖到这个SubGrid时,我希望subGridRowExpanded的绑定事件再次添加图标、展开行到网格。我该怎么做?
当加载subGridRowExpanded时,我解除了事件gridComplete的绑定:
function CreateOperationGrid(styleCode, styleSize, styleColorSerial, revNo) {
Operation_Grid.jqGrid({
datatype: "json",
height: 250,
width: null,
shrinkToFit: false,
rowNum: 100000,
rownumbers: true,
gridview: false,
//==========================================
url: "/OpsLink/GetOpDetail",
caption: "Operation",
postData: {
styleCode: styleCode, size: styleSize, serial: styleColorSerial, revNo: revNo
},
//mtype: 'POST',
colModel: [
{
name: "BenchmarkTime",
index: "BenchmarkTime",
width: 95,
label: arrColname.BENCHMARKTIME,
align: "center",
search: false,
sort: false
},
{ name: "StyleCode", index: "StyleCode", hidden: true },
{ name: "StyleSize", index: "StyleSize", hidden: true },
{ name: "StyleColorSerial", index: "StyleColorSerial", hidden: true },
{ name: "RevNo", index: "RevNo", hidden: true },
{ name: "OpRevNo", index: "OpRevNo", hidden: true },
{ name: "NewPrevNo", index: "NewPrevNo", hidden: true }
],
grouping: true,
groupingView: {
groupField: ["OpGroupName"],
groupColumnShow: [false],
groupCollapse: true,
plusicon: "ace-icon fa fa-plus",
minusicon: "ace-icon fa fa-minus"
},
subGrid: true,
subGridRowExpanded: function (subgridId, rowId) {
var row = Operation_Grid.getRowData(rowId);
var sCode = row.StyleCode;
var subgridTableId = subgridId + "_t";
jQuery("#" + subgridId).html("<table id='" + subgridTableId + "' class='scroll'></table>");
jQuery("#" + subgridTableId).jqGrid({
url: "/OpsLink/GetProtBomPattern?styleCode=" + sCode,
datatype: "json",
page: 1,
colModel: [
{ label: arrOpChilName.OpRevNo, name: "OpRevNo", index: "OpRevNo", width: 80 },
{ label: arrOpChilName.OpSerial, name: "OpSerial", index: "OpSerial", width: 80 },
{ label: arrOpChilName.OpType, name: "OpType", index: "OpType", width: 80 },
{ label: arrOpChilName.ConSumUnit, name: "ConSumUnit", index: "ConSumUnit", width: 80 },
{ label: arrOpChilName.UnitConSumTion, name: "UnitConSumTion", index: "UnitConSumTion", width: 80 },
{ label: arrOpChilName.PieceQty, name: "PieceQty", index: "PieceQty", width: 80 }
],
viewrecords: true,
height: "100%",
rownumbers: true,
multiselect: true,
pager: "#jqGridPager" + "_" + subgridId
});
},
subGridOptions: {
plusicon: "ace-icon fa fa-plus",
minusicon: "ace-icon fa fa-minus",
openicon: "ui-icon-carat-1-sw",
expandOnLoad: false,
selectOnExpand: false,
reloadOnExpand: false
},
gridComplete: function () {
Operation_Grid.find('tr[role="row"]').addClass("ui-droppable");
$('td[aria-describedby="Operation_Grid_NewPrevNo"]').each(function () {
var x = $(this).html();
if (x === " ") {
$(this).parent().find('td[aria-describedby="Operation_Grid_subgrid"]').unbind("click").html("");
}
});
}
});
}我要再次注册事件:
Operation_Grid.find('tr[id="' + rowDropTo + '"]').find('td[aria-describedby="Operation_Grid_subgrid"]').bind("click").html('<a style="cursor:pointer;"><span class="ui-icon ui-icon-plus"></span></a>');但当我点击图标时,它没有运行funtion。请帮忙,谢谢
发布于 2017-08-10 00:42:40
经过两天的研究,我已经像这样被重新绑定了。
= $(this).parent().find('tdaria-describedby="Operation_Grid_subgrid"').clone(true,true);$(this).parent().find('tdaria-describedby="Operation_Grid_subgrid"').unbind("click").html("");
发布于 2017-08-08 09:10:29
如果您使用古里多jqGrid,请查看我们的这里的演示示例
编辑:对于您的情况,另一个可能的解决方案是只显示和隐藏图标(在绑定中单击href标记),而不是绑定取消绑定事件。
https://stackoverflow.com/questions/45562530
复制相似问题