jquery.jqGrid.min.js无效

时间:2010-12-19 05:48:36

标签: 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 });

});

1 个答案:

答案 0 :(得分:3)

如何在jquery.jqGrid.min.js

的评论中看到
  

模块: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;

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

因此,您应该再次下载jqGrid,navGrid中使用jquery.jqGrid.min.js时不会有任何问题。