jqgrid custom formatter button click event not working

六眼飞鱼酱① 提交于 2019-12-23 01:41:52

问题


I have constructed a jqgrid dynamically, i am unable to invoke the function onclick of the button.

My Code:

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);
 }

}

The error i get always when i click on the buton in each row of jqgrid is "function is not defined"

My function is written right below the customFormatter function.

Please help me ASAP, thanks in advance.


回答1:


You have to put the testRow function out of the .ready() function.

e.g.

$(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);
}


来源:https://stackoverflow.com/questions/10704774/jqgrid-custom-formatter-button-click-event-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!