【问题标题】:Adding "Options" column to JQGrid?将“选项”列添加到 JQGrid?
【发布时间】:2013-08-16 23:00:54
【问题描述】:

我正在使用 Struts 2 的 JQuery 插件来显示一个网格 (jqGrid),但我想添加一个带有编辑、删除等选项的列。

我正在关注 jqGrid 官方文档中的本指南

http://trirand.com/blog/jqgrid/jqgrid.html

我在加载网格时订阅事件以向每一行添加内容,但呈现一个按钮只是显示纯 html 代码:

$(function(){
                $.subscribe("addOptions",function(){
                var ids=$("#procedimientos").jqGrid('getDataIDs');
                for(var i=0;i<ids.length;i++){
                    be = "<input style='height:22px;width:20px;' type='button' value='E' />";
                    $("#procedimientos").jqGrid('setRowData',ids[i],{opciones: be});
                }
            });

$("#procedimientos")这是我的网格

你能帮我吗:)?

【问题讨论】:

    标签: java jsp jqgrid struts2


    【解决方案1】:

    我们可以使用如下的格式化回调函数来渲染按钮

    colNames : 
          [ 'Name1',  
            'name2',  
          ],
        colModel : [ 
          {name : 'name1',index : 'id',width : 50,align : 'center'} , 
          {name : 'name2',index : 'name2',editable : false,width : 120,formatter:
          function (cellvalue, options, rowObject) { 
          if(cellvalue=='cond1'){
          return "<\input type='button' value='Add' onclick='func1(" + options.rowId + ")'/>"; 
        } 
        else if(cellvalue == 'cond2'){ 
        return "<\input type='button' value='Delete' onclick='func2(" + options.rowId + ")'/>"; 
        } 
        }
    } 
        ]
    

    【讨论】:

      猜你喜欢
      • 2021-01-07
      • 2019-10-24
      • 2023-03-30
      • 1970-01-01
      • 2012-01-03
      • 2011-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多