을 전환 참조 , 당신은 포크 jqGrid를 사용합니다. Tony Tomov는 상업적으로 Guriddo jqGrid JS을 개발했으며 free jqGrid을 개발했습니다. 완전히 무료로 사용할 수 있습니다.
무료 jqGrid 포크에 jqGrid의 이전 코드의 많은 부분을 다시 작성했습니다. 기능 중 하나 : "subgrid"
열을 격자의 다른 위치로 이동할 수 있습니다. 열을 재정렬하려면 remapColumns
이상의 새로운 remapColumnsByName
메서드를 사용해야합니다. 하나는 remapColumnsByName
의 마지막 열을 건너 뛸 수 있습니다.이 위치는 변경되지 않거나 먼저 표준 열 (예 : rownumbers: true
이 사용 된 경우 "rn"
열)을 건너 뛸 수 있습니다. 데모 https://jsfiddle.net/OlegKi/o1L8k2k6/는 열 "name"
및 "invdate"
후 "subgrid"
열을 이동하려면 다음 호출
.jqGrid("remapColumnsByName", ["name", "invdate", "subgrid"], true);
를 사용합니다. "-"당신이 "+"/ 배치해야하는 경우 하나는

같은 결과를 볼 것이다 다른 컬럼의 내부 아이콘을 다음 우선 사용해야합니다, 사용자 정의 포맷터 내부에있는 아이콘을 배치 열의 클릭을 감지하려면 beforeSelectRow
을 사용할 수 있습니다. 또한 .jqGrid("hideCol", "subgrid")
을 사용하여 표준 subgrid 열을 숨길 수 있습니다. 정의 포매터의 코드
formatter: function (cellValue) {
// place the icon using Font Awesome icons (http://fontawesome.io/)
// the the original data itself. One should encode the data
// with respect of $.jgrid.htmlEncode for example to be sure that
// ANY data could be correctly displayed in the column (like ' symbol)
return "<span class='mysubgrid fa fa-fw fa-plus'></span>" +
" " + $.jgrid.htmlEncode(cellValue);
}
https://jsfiddle.net/OlegKi/o1L8k2k6/2/가
같다 아 격자
beforeSelectRow: function (rowid, e) {
var $target = $(e.target), $subgridTd;
if ($target.hasClass("mysubgrid")) {
$subgridTd = $target.closest("tr.jqgrow>td")
.siblings("td")
.filter(".ui-sgcollapsed");
// simulate opening/closing of the subgrid
$target.removeClass("fa-minus fa-plus"); // remove both classes
$target.addClass(
$subgridTd.hasClass("sgexpanded") ?
"fa-plus" :
"fa-minus"
);
// simulate click on the original subgrid button
$subgridTd.find(".sgbutton").click();
}
return true; // allow selection of the row
}
에게 폐쇄/개방 처리 부가 beforeSelectRow
다음 코드를 사용 데모, 예를 들면, 수
멋쟁이지만 어떤 위치에 subgrid 더하기 기호를 적용하는 방법에 대한 도움을 찾을 수 없습니다 –
내가 말하는대로 플러스 기호를 추가하기 위해 formatter 또는 cellattr 이벤트를 사용한다. 이것을 수동으로 추가하고 클릭을 바인딩하거나 toggllSubGridRow를 실행할 onCellSelect 이벤트를 사용해야합니다.subgrid의 기본 더하기 부호의 위치는 변경할 수 없습니다. –