3
我刪除一行在jqGrid的像這樣:的jqGrid刪除行不刪除次網格
elem.jqGrid('delRowData', rowid);
但關聯到該行次網格依然存在。爲了使整行(包括子網格)消失,我還需要做哪些其他聰明的事情?
我刪除一行在jqGrid的像這樣:的jqGrid刪除行不刪除次網格
elem.jqGrid('delRowData', rowid);
但關聯到該行次網格依然存在。爲了使整行(包括子網格)消失,我還需要做哪些其他聰明的事情?
這似乎工作:
elem.jqGrid('collapseSubGridRow', rowid);
elem.jqGrid('delRowData', rowid);
嗯,還好。
你可以做的,而不是你貼下面的代碼:
var selRow = $('#'+rowid), // get the row (<tr> element having id=rowid)
nextRow = selRow.next(); // get the next row
if (nextRow.hasClass('ui-subgrid')) {
// if the next row is a subgrid one should remove it
nextRow.remove();
}
elem.jqGrid('delRowData', rowid);
// the call of delRowData is better as just selRow.remove();
// because it change "records" and "reccount" parameters and
// change parameters "selrow" and "selarrrow" in case that
// the deleted row was selected.
使用這種方法,如果你有設置爲「假」的reloadOnExpand選項,子網格行會留在網格中,雖然隱藏,並且不會被刪除。 – Schmuli