Jqgrid设置错误 - this.p未定义

时间:2011-05-09 04:22:06

标签: javascript jquery jqgrid

我是第一次尝试设置jqgrid,我的js导入如下,

<link rel="stylesheet" type="text/css" media="screen" href="css/jquery-ui-1.8.12.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.multiselect.css" />
<script src="http://code.jquery.com/jquery-1.5.2.min.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script src="js/jquery-ui-1.8.12.custom.min.js" type="text/javascript"></script>
<script src="js/jquery.contextmenu.js" type="text/javascript"></script>
<script src="js/jquery.searchFilter.js" type="text/javascript"></script>
<script src="js/jquery.tablednd.js" type="text/javascript"></script>
<script src="js/ui.multiselect.js" type="text/javascript"></script>
<script src="js/grid.loader.js" type="text/javascript"></script>

我收到一条错误,上面写着“第137行中的this.p未定义”。我不确定我是否错过了一些进口产品。对此的任何想法都会很棒。

谢谢, 阿比

@ Oleg评论后的更正导入,

<link rel="stylesheet" type="text/css" media="screen" href="css/jquery-ui-1.8.12.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />

<script src="js/jquery-1.5.2.min.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script src="js/jquery-ui-1.8.12.custom.min.js" type="text/javascript"></script>

似乎仍然不起作用:(

修改后的完整代码:

    <html>
<head>
<title>.: Sample :.</title>
<link rel="stylesheet" type="text/css" media="screen" href="css/jquery-ui-1.8.12.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />

<script src="js/jquery-1.5.2.min.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script src="js/jquery-ui-1.8.12.custom.min.js" type="text/javascript"></script>
<script>
/*if ($()) {  

 }*/

 $(document).ready(function(){
    for(var i=0;i<=mydata.length;i++){
            $("#table1").jqGrid('addRowData',i+1,mydata[i]);
        }
    }
 )

jQuery("#table1").jqGrid({ 
    datatype: "local", 
    height: 250, 
    colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], 
    colModel:[ 
        {name:'id',index:'id', width:60, sorttype:"int"}, 
        {name:'invdate',index:'invdate', width:90, sorttype:"date"}, 
        {name:'name',index:'name', width:100}, 
        {name:'amount',index:'amount', width:80, align:"right",sorttype:"float"}, 
        {name:'tax',index:'tax', width:80, align:"right",sorttype:"float"}, 
        {name:'total',index:'total', width:80,align:"right",sorttype:"float"}, 
        {name:'note',index:'note', width:150, sortable:false} 
        ], 
    multiselect: true, 
    caption: "Manipulating Array Data" 
});

var mydata = [ 
    {id:"1",invdate:"2007-10-01",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"}, 
    {id:"2",invdate:"2007-10-02",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"}, 
    {id:"3",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"}, 
    {id:"4",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"}, 
    {id:"5",invdate:"2007-10-05",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"}, 
    {id:"6",invdate:"2007-09-06",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"}, 
    {id:"7",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"}, 
    {id:"8",invdate:"2007-10-03",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},         
    {id:"9",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"}
 ];

</script>
</head>
<body>
<div id="outerDiv" style="border: 0px solid #060606; width: 100%; height: 100%;">
    <div style="border: 0px solid #060606; width: 100%; height: 25%;">Put whatever you want in here</div>
    <div style="border: 0px solid #060606; width: 100%; height: 23%;">
        <div style="border: 0px solid #060606; width: 50%; height: 99%;float:left;">
            <table id="table1"></table>
        </div>
        <div style="border: 0px solid #060606; width: 50%; height: 99%;float:right;">
            Div Right
        </div>
    </div>  
    <div style="border: 0px solid #060606; width: 100%; height: 23%;">
        <div style="border: 0px solid #060606; width: 50%; height: 99%;float:left;">
            Div Left
        </div>
        <div style="border: 0px solid #060606; width: 50%; height: 99%;float:right;">
            Div Right
        </div>
    </div>
    <div style="border: 0px solid #060606; width: 100%; height: 23%;">
        <div style="border: 0px solid #060606; width: 50%; height: 99%;float:left;">
            Div Left
        </div>
        <div style="border: 0px solid #060606; width: 50%; height: 99%;float:right;">
            Div Right
        </div>
    </div>
    <div style="border: 0px solid #060606; width: 100%; height: 6%;">

    </div>
</div>
</body>
</html>

1 个答案:

答案 0 :(得分:1)

您应该删除jquery.searchFilter.jsjquery.tablednd.jsgrid.loader.js并在<{strong> grid.locale-en.js之前添加jquery.jqGrid.min.js 加载。

如果您确实想使用grid.loader.js,则应检查文件是否包含grid.loader.js之后仅插入grid.loader.js中未包含的JS文件。规则是:不允许加载两次jqGrid模块。

更新:您需要在主JavaScript中进行一些更改。我的建议结果可以看到here

你应该怎么做:

  1. <!DOCTYPE ...元素之前添加<html>
  2. 将整个JavaScript代码放在$(document).ready(function(){内(不仅调用addRowData)。
  3. 使用data: mydata方法使用addRowData jqGrid参数更有效。
  4. 要获得完整的valide严格HTML代码,我在<tr><td/></tr>元素中包含<table>。如何在validator.w3.org上验证来自http://www.ok-soft-gmbh.com/jqGrid/Abhishek.htm的已修改代码没有验证错误。
  5. 我不太了解您使用的HTML页面设计。不过,我在clear:both;之后为第一个div添加了<table>样式,以便进入下一行。