jqgrid数据只加载一些列
jqgrid data only loading some columns
jqgrid 仅加载部分列。我一直无法找到一种模式来解释为什么有些列加载而其他列不加载。编辑列时,它会更新数据库。加载的字段将在编辑时刷新。第一列 acresHarvested 没有显示。还有一些没有出现。
<!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>
colModel 名称区分大小写,需要与 JSON 的大小写相匹配。另一个回复说Fiddler帮助查看返回的JSON.
jqgrid 仅加载部分列。我一直无法找到一种模式来解释为什么有些列加载而其他列不加载。编辑列时,它会更新数据库。加载的字段将在编辑时刷新。第一列 acresHarvested 没有显示。还有一些没有出现。
<!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>
colModel 名称区分大小写,需要与 JSON 的大小写相匹配。另一个回复说Fiddler帮助查看返回的JSON.