jqgrid - jquery.jqGrid.min.js 不工作

标签 jqgrid

我使用了 3.8.2 JQGrid 文件 jquery.jqGrid.min.js,它只是需要的文件,其中包含所有模块,下载时将从那里选择该文件,该文件不适用于其中一个错误 = }) .navGrid 不是函数。

我从 http://github.com/tonytomov/jqGrid/tree/master 下载了 tonytomov-jqGrid-c3a2a2d 文件夹并使用它,它具有驻留在 js 文件夹中的所有模块的路径并且工作正常。下面是来自 github 的 jquery.jqGrid.js 文件。我知道 jquery.jqGrid.js 是用于开发目的,但 jquery.jqGrid.min.js 根本不适合我。

这是为什么呢?我做了很多实验,这就是我所发现的。也许我错过了一些东西。

//This file should be used if you want to debug and develop
function jqGridInclude()
{
    var pathtojsfiles = "/Scripts/js/"; // need to be ajusted
    // set include to false if you do not want some modules to be included
    var modules = [
        { include: true, incfile:'i18n/grid.locale-en.js'}, // jqGrid translation
        { include: true, incfile:'grid.base.js'}, // jqGrid base
        { include: true, incfile:'grid.common.js'}, // jqGrid common for editing
        { include: true, incfile:'grid.formedit.js'}, // jqGrid Form editing
        { include: true, incfile:'grid.inlinedit.js'}, // jqGrid inline editing
        { include: true, incfile:'grid.celledit.js'}, // jqGrid cell editing
        { include: true, incfile:'grid.subgrid.js'}, //jqGrid subgrid
        { include: true, incfile:'grid.treegrid.js'}, //jqGrid treegrid
        { include: true, incfile:'grid.grouping.js'}, //jqGrid grouping 
        { include: true, incfile:'grid.custom.js'}, //jqGrid custom 
        { include: true, incfile:'grid.postext.js'}, //jqGrid postext
        { include: true, incfile:'grid.tbltogrid.js'}, //jqGrid table to grid
        { include: true, incfile:'grid.setcolumns.js'}, //jqGrid setcolumns
        { include: true, incfile:'grid.import.js'}, //jqGrid import
        { include: true, incfile:'jquery.fmatter.js'}, //jqGrid formater
        { include: true, incfile:'JsonXml.js'}, //xmljson utils
        { include: true, incfile:'grid.jqueryui.js'}, //jQuery UI utils
        { include: true, incfile:'jquery.searchFilter.js'} // search Plugin
    ];
    var filename;
    for(var i=0;i<modules.length; i++)
    {
        if(modules[i].include === true) {
            filename = pathtojsfiles+modules[i].incfile;
            if(jQuery.browser.safari) {
                jQuery.ajax({url:filename,dataType:'script', async:false, cache: true});
            } else {
                if (jQuery.browser.msie) {
                    document.write('<script charset="utf-8" type="text/javascript" src="'+filename+'"></script>');
                } else {
                    IncludeJavaScript(filename);
                }
            }
        }
    }
    function IncludeJavaScript(jsFile)
    {
        var oHead = document.getElementsByTagName('head')[0];
        var oScript = document.createElement('script');
        oScript.setAttribute('type', 'text/javascript');
        oScript.setAttribute('language', 'javascript');
        oScript.setAttribute('src', jsFile);
        oHead.appendChild(oScript);
    }
}
jqGridInclude();

//我的Js

jQuery().ready(function () {
    var lastSel;
    jQuery("#sandgrid").jqGrid({
        url: '/JQSandbox/MyGridData/',
        datatype: 'json',
        mtype: 'POST',
        height: 255,
        width: 640,
        colNames: ['Index', 'Name', 'City', 'State'],
        colModel: [
                { name: 'companyID', index: 'companyID', width: 5 },
                { name: 'companyName', index: 'companyName', width: 30 },
                { name: 'companyCity', index: 'companyCity', width: 30 },
                { name: 'companyState', index: 'companyState', width: 4, sortable: false}],

        pager: jQuery('#sandgridp'),
        rowNum: 5,
        rowList: [5, 10, 20, 50],
        sortname: 'companyID',
        sortorder: "desc",
        viewrecords: true,
        altRows: true,
        caption: 'Sandbox Grid',
        ondblClickRow: function (id) {
            if (id && id !== lastSel) {
                jQuery('#sandgrid').restoreRow(lastSel);
                lastSel = id;
                alert("You've seleted " + id);
            }
        },
        subGrid: true,
        subGridUrl: '/JQSandbox/MySubGridData/',
        subGridModel: [
        {
            name: ['Name', 'Department', 'Hire Date', 'Supervisor'],
            width: [80, 20, 80, 10],
            align: ['left', 'left', 'left', 'center'],
            params: ['companyID']
        }]
    }).navGrid('#sandgridp', { edit: false, add: false, del: false });

});

最佳答案

如何在jquery.jqGrid.min.js的注释中看到

Modules: grid.base.js; jquery.fmatter.js; grid.custom.js; grid.common.js; jquery.searchFilter.js; grid.inlinedit.js; grid.celledit.js; jqModal.js; jqDnR.js; grid.subgrid.js; grid.grouping.js; grid.treegrid.js; grid.import.js; JsonXml.js; grid.setcolumns.js; grid.postext.js; grid.tbltogrid.js; grid.jqueryui.js;

您选择了所有 jqGrid 模块,但 grid.formedit.js 除外。在 the jqGrid download page它的名称为“表单编辑”(请参阅​​“编辑”组)。我测试过,现在可以从 the jqGrid download page 下载所有模块。所以这应该不是技术问题。

所以你应该再下载一次jqGrid,在jquery.jqGrid.min.js中使用navGrid就不会有任何问题了。

关于jqgrid - jquery.jqGrid.min.js 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4481799/

相关文章:

javascript - jqgrid 中的复选框选中或取消选中

javascript - 如何使用 JqGrid 子网格进行内联编辑?

javascript - jqGrid 列未与列标题对齐

jquery - 即使使用正确的参数也无法显示最后一页

c# - 如何将额外的 postdata 传递到添加记录函数 - JQGrid-MVC。网

javascript - tableToGrid jqgrid可排序问题

c# - 在 jqGrid 中,读取与保存单个属性/列是否有不同的值?

javascript - jqGrid - 我如何禁用可拖动列但可以排序列

javascript - 在 JqGrid 列中创建动态 FTP 链接

javascript - jQuery 按钮单击 jqGrid 的刷新仅触发一次