【问题标题】:jQGrid - reordering action buttons on sorting rowsjQGrid - 对排序行重新排序操作按钮
【发布时间】:2014-05-28 09:36:34
【问题描述】:

我们如何根据关注行的排序重新排列 jQGrid 中操作按钮(编辑和删除)的排序顺序?

HTML:

<table id="grid"></table>

这是我的fiddle

我在网格中编写了不同的编辑按钮和保存按钮。

如果有人觉得我的查询难以理解,我会更新这篇文章。

谢谢

【问题讨论】:

    标签: javascript jquery sorting jqgrid


    【解决方案1】:

    我建议使用呈现按钮的自定义格式函数 (formatter)。在每个按钮上,您可以使用行参数设置点击处理程序

     colModel:[
        {name:'act',index:'act', width:120, sortable:false, formatter: customFormat},
        {name:'emp_name', index:'emp_name', key: true, width:100, editable:true},
        {name:'emp_id', index:'emp_id', width:80, editable:true},
        {name:'addr', index:'addr', width:100, editable:true}
    ],
    
    
    function customFormat (cellvalue, options, rowObject) {
        console.log(rowObject);
        return '<input type="button" class="editbtn" value="edit" onclick="console.log('+rowObject.emp_id+')"/><input type="button" class="delbtn" value="del" onclick="console.log('+rowObject.emp_id+')"/>';
    }
    

    知道点击了哪个 emp_id,您可以调用您自己的自定义函数,该函数将对该 emp_id 做一些事情

    See fiddle

    【讨论】:

      猜你喜欢
      • 2012-03-20
      • 1970-01-01
      • 1970-01-01
      • 2013-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多