Jquery jqgrid自定义按钮列加载完成
我正在使用带有自定义按钮列的Jqgrid。我使用jqgrid的LoadComplete方法填充按钮。下面是我在load complete中使用的代码Jquery jqgrid自定义按钮列加载完成,jquery,jquery-ui,jqgrid,Jquery,Jquery Ui,Jqgrid,我正在使用带有自定义按钮列的Jqgrid。我使用jqgrid的LoadComplete方法填充按钮。下面是我在load complete中使用的代码 var grid = $("#grid"), iCol = getColumnIndexByName(grid,'custom'); // 'custom' - name of the actions column grid.children("tbody")
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;
};
var grid=$(“#grid”),
iCol=getColumnIndexByName(网格,'custom');/'自定义”-操作列的名称
表格.儿童(“tbody”)
.儿童(“tr.jqgrow”)
.儿童(“td:n个儿童(“+(iCol+1)+”))
.each(函数({
$("",
{
标题:“按钮1”,
mouseover:function(){
$(this.addClass('ui-state-hover');
},
mouseout:function(){
$(this.removeClass('ui-state-hover');
},
点击:
在这里处理你的点击功能
}
).css({“左边距”:“5px”,float:“left”})
.addClass(“ui pg div ui内联保存”)
.attr('id','customId')
.append(“”)
.appendTo($(this.children)(“div”);
)};
var getColumnIndexByName=函数(网格,columnName){
var cm=grid.jqGrid('getGridParam','colModel'),i=0,l=cm.length;
对于(;i您应该查看自定义格式化程序
在列中,您可以在colmodel中定义一个格式化程序,该格式化程序为网格的每一行触发。然后您可以执行以下操作:
function formatterName(cellvalue, rowid, rowObject)
{
if(rowObject[1] == "YourValue" && rowObject[2] == "YourValue"){ // index for choosing which column to check
// run code for displaying buttons in the columns that matches your criteria
}
}