Skip to content Skip to sidebar Skip to footer

Jqgrid.info_dialog Is Not A Function, Do I Have To Call Extend?

I try to use info_dialog on my jqGrid, but see TypeError: $(...).jqGrid.info_dialog is not a functionin the console. I have (!) not defined my own info_dialog function. But I can s

Solution 1:

jqGrid defines not only "standard" methods, which can be used as $("#grid").jqGrid("methodName", ...) or $("#grid").methodName(...), but some other methods. The "standard" methods will be registered under $.fn.jqGrid.methodName (like $.fn.jqGrid.editGridRow function for example) and, if no $.jgrid.no_legacy_api = true; is specified before $.jgrid.no_legacy_api = true;, then under $.fn.methodName too.

In other words there are exist only global object $.fn.jqGrid or $.fn, which contains the "standard" jqGrid methods.

Some other list of methods will be registered under $.jgrid instead of $.fn.jqGrid or $.fn. info_dialog is an example of such method. Thus one should use $.jgrid.info_dialog, $.jgrid.jqID, $.jgrid.htmlEncode, $.jgrid.randId and so on to use such methods. The most of the methods don't require to initialize this (like $.jgrid.randId()$.jgrid.jqID("some.text")), but some methods require that this is initialized to DOM of the grid (the empty <table> used to generate the grid).

For example, you can use

$grid.jqGrid("navButtonAdd", "#pager", {
    caption: "Test",
    onClickButton: function () {
        $.jgrid.info_dialog.call(this,
            "Warning with two buttons",
            "Click the `test` button",
            "Close",
            {
                buttons: [
                    {
                        text: "\"text\" button",
                        id: "buttid",
                        onClick: function() {
                            alert("click...");
                        }
                    }
                ]
            }
        );
    }
});

See https://jsfiddle.net/OlegKi/xLrbdspo/. I use in the demo free jqGrid fork, which I develop, but the same works with the retro version 4.6 of jqGrid, which you use.

The final remark. If you know the syntax of TypeScript, that you can find in free-jqgrid.d.ts answers on many of questions like the usage of info_dialog. The methods and properties of $.jgrid are described here (inclusive info_dialog). You will find here additionally some methods $.fmatter, $.jqm, $.jqDnR and $.unformat which are the part of jqGrid in the same way like $.jgrid.

Post a Comment for "Jqgrid.info_dialog Is Not A Function, Do I Have To Call Extend?"