【问题标题】:jqgrid custom formatter button click event not workingjqgrid自定义格式化程序按钮单击事件不起作用
【发布时间】:2012-05-29 02:32:35
【问题描述】:

我已经动态构建了一个jqgrid,我无法调用按钮的onclick函数。

我的代码:

function buildButtons(cellvalue, options, rowObject) {
            var optionsRowId = options.rowId;
            var editDelButtons = "<input style=\"height:22px;width:40px;\" type=\"button\" value=\"Edit\" onclick=\"javascript:testRow('" + optionsRowId + "')\" />";
            return editDelButtons;

        }

function testRow(rowID)
{
  alert(rowID);
 }

}

当我点击 jqgrid 每一行中的按钮时,我总是得到的错误是“函数未定义”

我的函数写在 customFormatter 函数的正下方。

请尽快帮助我,在此先感谢。

【问题讨论】:

  • 你能发布一个更大的代码示例(例如:jsfiddle)来演示这个问题吗?

标签: jqgrid jqgrid-asp.net jqgrid-formatter


【解决方案1】:

你必须把testRow函数从.ready()函数中去掉。

例如

$(function(){

    function buildButtons(cellvalue, options, rowObject) {
        var optionsRowId = options.rowId;
        var editDelButtons = "<input style=\"height:22px;width:40px;\" type=\"button\" value=\"Edit\" onclick=\"javascript:testRow('" + optionsRowId + "')\" />";

        return editDelButtons;
    }

})

function testRow(rowID)
{
    alert(rowID);
}

【讨论】:

    猜你喜欢
    • 2014-02-10
    • 1970-01-01
    • 1970-01-01
    • 2015-12-27
    • 2018-02-24
    • 2012-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多