0
사용자 정의 버튼 열과 함께 Jqgrid를 사용하고 있습니다. jqgrid의로드 완료 메소드를 사용하여 버튼을 채 웁니다. 로드 완료에서 사용하는 코드 아래.로드 중 jqgrid 사용자 정의 버튼 열
var grid = $("#grid"),
iCol = getColumnIndexByName(grid,'custom'); // 'custom' - name of the actions column
grid.children("tbody")
.children("tr.jqgrow")
.children("td:nth-child("+(iCol+1)+")")
.each(function() {
$("<div>",
{
title: "button1",
mouseover: function() {
$(this).addClass('ui-state-hover');
},
mouseout: function() {
$(this).removeClass('ui-state-hover');
},
click:
handle your click function here
}
).css({"margin-left": "5px", float:"left"})
.addClass("ui-pg-div ui-inline-save")
.attr('id',"customId")
.append('<span class="ui-button-icon-primary ui-icon ui-icon-disk"></span>')
.appendTo($(this).children("div"));
)};
var getColumnIndexByName = function(grid,columnName) {
var cm = grid.jqGrid('getGridParam','colModel'), i=0,l=cm.length;
for (; i<l; i+=1) {
if (cm[i].name===columnName) {
return i; // return the index
}
}
return -1;
};
모든 행에 버튼이 표시됩니다. 하지만 첫 번째 및 두 번째 열의 값을 기반으로 몇 행에 대해서만 표시되도록하고 싶습니다. 첫 번째와 두 번째 열 값을 얻을 수있는 쉬운 방법이 있습니까? 아니면 "tbody"를 다시 반복하고 결과를 검색해야합니까? 도와주세요.