jqGrid.info_dialog不是一个函数,我必须调用extend吗? [英] jqGrid.info_dialog is not a function, do I have to call extend?

查看:100
本文介绍了jqGrid.info_dialog不是一个函数,我必须调用extend吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在jqGrid上使用info_dialog,但请在控制台中查看TypeError: $(...).jqGrid.info_dialog is not a function.

I try to use info_dialog on my jqGrid, but see TypeError: $(...).jqGrid.info_dialog is not a functionin the console.

我没有定义(!)我自己的info_dialog函数.但我可以在$.extend($.jgrid, ...中看到它,例如这里,因此我期望它默认情况下可用.

I have (!) not defined my own info_dialog function. But I can see one it in $.extend($.jgrid, ... like here, so I was expecting it is available by default.

info_dialog : function(caption, content,c_b, modalopt) {
        var mopt = {
            width:290,
            height:'auto',

我是否必须以某种方式为网格启用它?或我还必须做些什么,以便可以使用定义的版本

Do I somehow have to enable it for the grid? Or what else do I have to do so I can use the version defined here (call extend on my grid? ..)

使用> https://cdnjs.com/libraries/jqgrid 中的4.6.0
现在使用 https://cdnjs.com/libraries/free-jqgrid 4.14.1

Using 4.6.0 from https://cdnjs.com/libraries/jqgrid
Now using https://cdnjs.com/libraries/free-jqgrid 4.14.1

推荐答案

jqGrid不仅定义了可以用作$("#grid").jqGrid("methodName", ...)$("#grid").methodName(...)的标准"方法,还定义了一些其他方法. 标准"方法将在$.fn.jqGrid.methodName下注册(例如,像$.fn.jqGrid.editGridRow函数),如果在$.jgrid.no_legacy_api = true;之前未指定$.jgrid.no_legacy_api = true;,则也将在$.fn.methodName下注册.

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.

换句话说,仅存在全局对象$.fn.jqGrid$.fn,其中包含标准" jqGrid方法.

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

一些其他方法列表将在$.jgrid下而不是$.fn.jqGrid$.fn下注册. info_dialog是此类方法的示例.因此,应该使用$.jgrid.info_dialog$.jgrid.jqID$.jgrid.htmlEncode$.jgrid.randId等来使用此类方法.大多数方法不需要初始化this(如$.jgrid.randId() $.jgrid.jqID("some.text")),但是某些方法要求将this初始化为网格的DOM(用于生成网格的空<table> ).

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).

例如,您可以使用

$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...");
                        }
                    }
                ]
            }
        );
    }
});

请参见 https://jsfiddle.net/OlegKi/xLrbdspo/.我在演示中使用了开发的免费jqGrid 分支,但与Retro相同使用的jqGrid 4.6版.

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.

最后一句话.如果您知道TypeScript的语法,则可以在此处(包括 info_dialog ).您将在此处找到另外,某些方法$.fmatter$.jqm$.jqDnR$.unformat都是jqGrid的一部分,就像$.jgrid一样.

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.

这篇关于jqGrid.info_dialog不是一个函数,我必须调用extend吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆