jQgrid插件根据一列,控制另一列的输出


jQgrid开发中,往往会遇到以下情况,根据某一列的值,去控制另一列的显示输出。
代码如下:根据transportType(为0或1)去控制enterpriseName字段的显示。
当transportType为1时,则enterpriseName显示:“本单位”,当为0时,则显示根据数据库读出的数据。


$("#xxxxx").jqGrid({
            url: "${pageContext.request.contextPath}/***/get***.do",
            datatype: "json",
            mytype: 'GET',
            colNames:["orderId","tmId","transportType","发货点", "**打印时间", "发货时间","预到货时间","**牌名","数量(万支)","数量(箱)","单位","车牌","备注"],
            colModel:[
                      {name: "orderId",hidden:true},
                      {name: "tmId",hidden:true},
                      {name: "transportType",hidden:true},
                      {name: "repertoryName"},
                      {name: "printDate"},
                      {name: "plannedDepartedDate"},
                      {name: "plannedArrivedDate"},
                      {name: "productName"},
                      {name: "pNumber"},
                      {name: "lNumber"},
                      {name: "enterpriseName",formatter: function(cellValue,options,rowObject){if(rowObject.transportType=="1") return "本单位";else{return rowObject.enterpriseName;}}},
                      {name: "plateNumber"},
                      {name: "remark"}
                      ],


你可能感兴趣的:(jqGrid)