【问题标题】:JqGrid Add button object with SetRowDataJqG​​rid 使用 SetRowData 添加按钮对象
【发布时间】:2012-08-23 06:43:32
【问题描述】:

我在 gridComplete 中使用 setRowData 将两个按钮添加到我的 JQGrid 中名为“Actions”的列中。它完美地工作但是由于最近的更改,我不得不从传递 html 切换到 setRowData 以某种方式传递两个按钮对象...更改后,setRowData 导致 [object Object] 显示在列中...我只是想知道将两个按钮对象添加到 jqGrid 中的列的最佳方法是什么?我应该改用 SetCell 吗?

谢谢, HS

编辑: 谢谢你们的回复。但是我不确定我是否遵循您的答案...也许我没有清楚地描述可能...我按照this 帖子中的方法将我的按钮添加到“操作”列。但是由于最近的更改,我不得不像这样创建我的按钮:

acceptButton = $('<button class="ui-state-default ui-corner-all"><span class="ui-button-text">Accept</span></button>',{click:function(){ AcceptNewValue(gridId,currentRow["UserID"],'') }});
rejectButton = $('<button class="ui-state-default ui-corner-all"><span class="ui-button-text">Reject</span></button>', {click:function(){ RejectNewValue(gridId,currentRow["UserID"],'') }});

问题是我现在如何将两个按钮都添加到网格的“操作”列中?所有行上都应该出现两个按钮...当点击不同行的按钮时,不同的 UserID 将被传递到点击函数中。

谢谢, HS

【问题讨论】:

  • 如果唯一的要求是在 gridComplete 中添加按钮,使用您的 setRowData 并在 loadComplete 中添加按钮代码。

标签: jquery jqgrid


【解决方案1】:

我在创建 jqGrid 时使用afterInsertRow: function(rowid, rowdata, rowelem) 回调,然后

$(this).jqGrid('setCell', rowid, '[col_id]', '简单按钮');

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-02-25
    • 2023-03-29
    • 2018-03-26
    • 2016-07-04
    • 2013-10-15
    • 2011-01-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多