我是第一次尝试设置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>
答案 0 :(得分:1)
您应该删除jquery.searchFilter.js
,jquery.tablednd.js
和grid.loader.js
并在<{strong> grid.locale-en.js
之前添加jquery.jqGrid.min.js
加载。
如果您确实想使用grid.loader.js
,则应检查文件是否包含grid.loader.js
之后仅插入grid.loader.js
中未包含的JS文件。规则是:不允许加载两次jqGrid模块。
更新:您需要在主JavaScript中进行一些更改。我的建议结果可以看到here。
你应该怎么做:
<!DOCTYPE ...
元素之前添加<html>
。$(document).ready(function(){
内(不仅调用addRowData
)。<tr><td/></tr>
元素中包含<table>
。如何在validator.w3.org上验证来自http://www.ok-soft-gmbh.com/jqGrid/Abhishek.htm的已修改代码没有验证错误。clear:both;
之后为第一个div添加了<table>
样式,以便进入下一行。