Coldfusion jqgrid数据仅加载某些列

Coldfusion jqgrid数据仅加载某些列,coldfusion,jqgrid,Coldfusion,Jqgrid,jqgrid仅加载部分列。我还没有找到一个模式来解释为什么一些列加载而其他列不加载。编辑列时,它会更新数据库。进行加载的字段将在编辑时刷新。第一列acresharved没有显示。还有其他人也没有出现 <!DOCTYPE html> <html lang="en"> <head> <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/theme

jqgrid仅加载部分列。我还没有找到一个模式来解释为什么一些列加载而其他列不加载。编辑列时,它会更新数据库。进行加载的字段将在编辑时刷新。第一列acresharved没有显示。还有其他人也没有出现

<!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>

$(“文档”).ready(函数(){
jQuery(“prodgrid”).jqGrid({
url:'cfc/productionfacts.cfc?method=jqgridCP&croprofileid=#url.croprofileid#',
宽度:“自动”,
高度:“自动”,
数据类型:“json”,
colNames:[“收获的英亩数”、“ID”、“生产年份”、“USRank”、“美国英亩数”、“种植的英亩数”、“产量”、“生产价值”、“生产成本率”、“州平均产量”、“natlAvgPerAcre”、“价格”、“每英亩价值”、“种植者”、“单位”],
colModel:[
{名称:'acresharested',索引:'acresharested',搜索:true,可编辑:true,宽度:100},
{名称:'cpproductionfactid',索引:'cpproductionfactid',搜索:true,可编辑:false,宽度:50},
{名称:'productionyear',索引:'productionyear',搜索:true,可编辑:true,宽度:150},
{名称:'usrank',索引:'usrank',搜索:true,可编辑:true,宽度:50},
{名称:'usacrescenter',索引:'usacrescenter',搜索:true,可编辑:true,宽度:50},
{名称:'acresPlanted',索引:'acresPlanted',搜索:true,可编辑:true,宽度:100},
{名称:'production',索引:'production',搜索:true,可编辑:true,宽度:100},
{名称:'productionvalue',索引:'productionvalue',搜索:true,可编辑:true,宽度:100},
{名称:'productionCostsPerAcre',索引:'productionCostsPerAcre',搜索:true,可编辑:true,宽度:100},
{名称:'stateAvgPerAcre',索引:'stateAvgPerAcre',搜索:true,可编辑:true,宽度:100},
{名称:'natlAvgPerAcre',索引:'natlAvgPerAcre',搜索:true,可编辑:true,宽度:100},
{名称:'price',索引:'price',搜索:true,可编辑:true,宽度:100},
{名称:'perAcreValue',索引:'perAcreValue',搜索:true,可编辑:true,宽度:100},
{名称:'growers',索引:'growers',搜索:true,可编辑:true,宽度:100},
{名称:'unit',索引:'unit',搜索:true,可编辑:true,宽度:100}
],
jsonReader:{repeatitems:false,id:“cpproductionfactid”},
rowNum:10,
行数:对,
行列表:[10,20,30],
sortname:“生产年份”,
viewrecords:是的,
recordtext:“{2}的记录{0}-{1}”,//要显示的寻呼机信息
巫师:“描述”,
editurl:“cfc/productionfacts.cfc?方法=editProdFact&CropRofileId=#url.CropRofileId#”,
描述:“生产事实”,
寻呼机:“#寻呼机”
});
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',{searchOneNoter:false});
});


colModel名称区分大小写,需要与JSON的大小写匹配。正如在另一个响应中所述,Fiddler帮助查看返回的JSON。

如果您在加载数据时遇到问题,那么您应该包括从服务器接收的测试数据。包含两行数据就足够了。包含真实数据很重要。例如,如果名称的大小写(如
acresharvedt
)不完全相同,则可能是问题所在。我建议你使用IE/Chrome/Firefox的开发者工具来跟踪HTTP流量。我建议您将
块从
移动到
<代码>$(“文档”)。准备就绪(..)内部的
看起来很奇怪。感谢您的回复。事实证明,CF JSON序列化正在将字段转换为所有小写。我使用的是在colModel中的CF查询中检索到的字母大小写,而不是所有小写JSON数据:“usacrespercent”:0,colModel:{name:'usacrespercent',index:'usacrespercent',search:true,editable:true,width:50},