jqgrid数据只加载一些列

时间:2015-04-21 20:10:46

标签: coldfusion 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>

1 个答案:

答案 0 :(得分:0)

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