如何在子网格中绑定和解除绑定事件
当subGridRowExpanded时,我有一个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 subGridRowExpanded。请帮忙,谢谢
经过两天的研究,我被重新绑定了这样的嫌疑人。
- 之前除去脓它到一个数组:
currChild [ID] = $(本).parent()找到( 'TD [咏叹调-describedby = “Operation_Grid_subgrid”]')。克隆(true,true); ()“)。(())。(this).parent()。find('td [aria-describedby =”Operation_Grid_subgrid“]')。unbind(”click“)。
bin又一次。 Operation_Grid.find('tr [id =''+ rowDropTo +'“]')。find('td [aria-describedby =”Operation_Grid_subgrid“]')。replaceWith(currChild [rowDropTo]);
在您使用Guriddo jqGrid情况,请关注我们demo example here
编辑:对于你的情况的另一种可能的解决方案是只是为了而非显示和隐藏图标(其中单击绑定href标记)绑定解除绑定事件。