0
jqgrid只加載一些列。我一直無法找到一個模式,爲什麼一些列加載,而另一些則沒有。列編輯時,它會更新數據庫。編輯後,加載的字段將刷新。第一列,英畝收入,沒有出現。還有其他人也沒有出現。jqgrid數據只加載一些列
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/themes/cupertino/jquery-ui.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.8.0/css/ui.jqgrid.css" type="text/css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.8.0/js/i18n/grid.locale-en.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.8.0/js/jquery.jqgrid.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"></script>
</head>
<body>
<script type="text/javascript">
$("document").ready(function() {
jQuery("#prodgrid").jqGrid({
url:'cfc/productionfacts.cfc?method=jqgridCP&cropprofileid=<cfoutput>#url.cropprofileid#</cfoutput>',
width:"auto",
height:"auto",
datatype: "json",
colNames:['Acres Harvested','ID','Production Year', 'USRank', 'US Acres', 'Acres Planted', 'Production', 'Production Value', 'productionCostsPerAcre', 'stateAvgPerAcre', 'natlAvgPerAcre', 'Price', 'Per Acre Value', 'Growers', 'Unit'],
colModel:[
{name:'acresHarvested',index:'acresHarvested', search: true, editable:true, width:100},
{name:'cpproductionfactid',index:'cpproductionfactid', search: true, editable:false, width:50 },
{name:'productionyear',index:'productionyear', search: true, editable: true, width:150},
{name:'usrank',index:'usrank', search: true, editable:true, width:50},
{name:'USAcresPercent',index:'USAcresPercent', search: true, editable:true, width:50},
{name:'acresPlanted',index:'acresPlanted', search: true, editable:true, width:100},
{name:'production',index:'production', search: true, editable:true, width:100},
{name:'productionvalue',index:'productionvalue', search: true, editable:true, width:100},
{name:'productionCostsPerAcre',index:'productionCostsPerAcre', search: true, editable:true, width:100},
{name:'stateAvgPerAcre',index:'stateAvgPerAcre', search: true, editable:true, width:100},
{name:'natlAvgPerAcre',index:'natlAvgPerAcre', search: true, editable:true, width:100},
{name:'price',index:'price', search: true, editable:true, width:100},
{name:'perAcreValue',index:'perAcreValue', search: true, editable:true, width:100},
{name:'growers',index:'growers', search: true, editable:true, width:100},
{name:'unit',index:'unit', search: true, editable:true, width:100}
],
jsonReader: {repeatitems: false, id: "cpproductionfactid"},
rowNum:10,
rownumbers:true,
rowList:[10,20,30],
sortname: 'productionyear',
viewrecords: true,
recordtext: "Record {0} - {1} of {2}",//Pager information to show
sortorder: "desc",
editurl:"cfc/productionfacts.cfc?method=editProdFact&cropprofileid=<cfoutput>#url.cropprofileid#</cfoutput>",
caption:"Production Facts",
pager: '#pager'
});
jQuery("#prodgrid").jqGrid('navGrid', '#pager', {edit: true, add: true, del: false, search: false},
{closeAfterEdit: true},
{closeAfterAdd: true}
);
jQuery("#prodid").jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid');
//reloadAfterSubmit: true, closeOnEscape: true,afterSubmit:processEdit,closeAfterEdit: true,closeAfterSubmit: true}
jQuery("#prodgrid").jqGrid('filterToolbar',{searchOnEnter:false});
});
</script>
<table id="prodgrid"></table>
<div id="pager"></div><br>
</body>
</html>
如果您在加載**數據時遇到問題,那麼您應該包含從服務器收到的測試數據。包含兩行數據就足夠了。包含**真實數據**非常重要。例如,如果名稱的情況(比如'acresHarvested')不完全相同,則可能是問題所在。我建議您使用[Fiddler](http://www.telerik.com/fiddler)或IE/Chrome/Firefox的開發工具來跟蹤HTTP流量。我建議你將'