【问题标题】:Create button JqGrid创建按钮 JqGrid
【发布时间】:2017-11-20 07:45:07
【问题描述】:

我使用 JqGrid 构建表格,当我选择一行时,我得到 onSelectRow 操作。表格中还有一个带有按钮的列,我使用格式化程序创建。如何使 onSelectRow 事件在单击按钮时不起作用?

格式化程序:

function btnCopyZn(rowId, cellValue, rowObject) 
{
   return "<button onClick='clickFunctionCopyZn(" + rowId + ")' class='btn btn-xs btn-default'>" 
          + '<sapn class="glyphicon glyphicon-copy"></span>' 
          + "</button>";
}

函数副本:

function clickFunctionCopyZn(rowId) 
{
   if (rowId != null) 
   {
     var input = document.createElement("input");
     input.value = rowId;
     document.body.appendChild(input);
     input.select();
     document.execCommand("Copy");
     document.body.removeChild(input);
   }
}

onSelectRow:

model.tableTreeGrid.setGridParam({
onSelectRow: function () 
{
// function
}
});

【问题讨论】:

  • 分享您正确的代码,以便我们查看并帮助您
  • @KresimirPendic,问题已更新。

标签: javascript jquery jqgrid


【解决方案1】:

如果您使用 Guriddo jqGrid,那么一种可能的解决方案是使用另一个名为 beforeSelectRow 的事件。

当用户点击该行时触发此事件,但在选择它们之前。此事件应返回布尔值 true 或 false。如果事件返​​回 true,则选择完成。如果事件返​​回 false,则不会选择行,并且不会发生任何其他操作(onCellSelect 除外)(如果已定义)。

传递给这个事件的参数是rowid和事件处理函数。

$("#jqGrid").jqGrid({
...
   beforeSelectRow : function( rowid, ev ) {
      if( condition_not_to_selectrow) {
         return false;
      } else {
         return true;
      }
   },
...
});

【讨论】:

    猜你喜欢
    • 2020-10-15
    • 1970-01-01
    • 2011-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多