关于jqgrid的应用。
html.body{ margin:0; padding:0; font-size:75%; } jQuery("#list1").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:90,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-10-03",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"}, {id:"4",invdate:"2007-10-04",name:"test4",note:"note4",amount:"500.00",tax:"40.00",total:"210.00"}, {id:"5",invdate:"2007-10-05",name:"test5",note:"note5",amount:"600.00",tax:"50.00",total:"320.00"}, {id:"6",invdate:"2007-10-06",name:"test6",note:"note6",amount:"700.00",tax:"60.00",total:"430.00"}, {id:"7",invdate:"2007-10-07",name:"test7",note:"note7",amount:"800.00",tax:"70.00",total:"210.00"}, ]; for(var i = 0;i < mydata.length;i++){ jQuery("#list1"),jqGrid('addRowData',i+1,mydata[1]); } 测试文档
以上是全部源代码。我想知道。为什么没有反应。是我引入文件错了吗?

2个回答

首先你需要调整jquery的位置
jquery.js的引入应该放在所有js的前面

其次,jQuery("#list1").jqGrid 需要在页面渲染完成之后执行
要么把你那段代码放在html页面的最下面,要么在代码外面套上$(function(){})

需要放在前面,另外,报错信息是什么

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!