firebug中显示调用action得到了json数据,但就是在grid中显示不出来

 

MES.compGrid构造器如下:

 

MES.compGrid=function(config){

    this.store=new Ext.data.JsonStore({

       url:config.storeUrl,

//     root:config.storeRoot,

       root:'root',

       fields:[{

                  name:'componentItem.level'

           },{

                  name:'component.compId'

           },{

                  name:'component.componentName'

           },{

                  name:'component.standard'

           },{

                  name:'componentItem.number'

           },{

                  name:'component.partNum'

           }]

    });

    this.store.load();

   

    var rn = new Ext.grid.RowNumberer();

   

    var cm = new Ext.grid.ColumnModel({

       columns:[rn,{

                  header:'工件层级',

                  dataIndex:'componentItem.level'

           },{

                  id:'compId',

                  header:'工件编号',

                  dataIndex:'component.compId'

           },{

                  header:'工件名称',

                  dataIndex:'component.componentName'

           },{

                  header:'规格型号',

                  dataIndex:'component.standard'

           },{

                  header:'数量',

                  dataIndex:'componentItem.number'

           },{

                  header:'材料编号',

                  dataIndex:'component.partNum'

           }]

    });

   

    var default_config={

       storeUrl:' ',

//     storeRoot:' ',

       cm:cm,

       autoExpandColumn:'compId',

       viewConfig:{

           forceFit:true

       }

    };

    config=Ext.applyIf(config || {} , default_config);

    MES.compGrid.superclass.constructor.call(this,config);

      

};

Ext.extend(MES.compGrid,Ext.grid.GridPanel,{});

    });

   

 

 

新构造的grid如下:

    this.bom_comp=new MES.compGrid({

       id:'bom_comp',

       storeUrl:'/commonMes/bom/getItem.action',

//     storeRoot:'root',

       tbar:[{xtype: 'tbspacer', width: 100

           },{

              pressed:true,text:'修改本bom'

           },'-',{

              pressed:true,text:'录入工件工艺'

           },'-',{

              pressed:true,text:'修改工件工艺'

           }],

       title:'工件列表',

       width:550,

       height:450,

       collapsible:true

    });

 

 

 

返回json数据如下:

{"root":[{"component.componentName":"plate","component.compId":"d6-b2","componentItem.level":"1.1","component.partNum":"pt008","componentItem.number":500,"component.standard":"GB-888"},{"component.componentName":"nut","component.compId":"d6-b1","componentItem.level":"1.2","component.partNum":"pt009","componentItem.number":2000,"component.standard":"GB-065"},{"component.componentName":"platenut","component.compId":"d6","componentItem.level":"1","componentItem.number":500,"component.standard":""},{"component.componentName":"platenut","component.compId":"","componentItem.level":"1","componentItem.number":1},{"component.componentName":"nut","componentItem.level":"1.2","component.partNum":"pt009","componentItem.number":4,"component.standard":"GB-065"},{"component.componentName":"plate","componentItem.level":"1.1","component.partNum":"pt008","componentItem.number":1,"component.standard":"GB-888"}]}

 

 

 

 

 

问题:firebug中显示调用action得到的json数据如上,都是我要的数据,但就是在grid中显示不出来。

 

解决方法:将下面

fields:[{

                  name:'componentItem.level'

           },{

                  name:'component.compId'

           },{

                  name:'component.componentName'

           },{

                  name:'component.standard'

           },{

                  name:'componentItem.number'

           },{

                  name:'component.partNum'

           }]

 

改为:

fields:[{

                  name:'level'

           },{

                  name:'compId'

           },{

                  name:'componentName'

           },{

                  name:'standard'

           },{

                  name:'number'

           },{

                  name:'partNum'

           }]

 

注意:这种component.compId点后缀命名方式使得后台json数据无法显示!!一定不要这样命名!呜呜,调这个调了一天!

另外,构造器真不好用!代码重用固然好,可是稍微有地方改动了,不适用,就容易出现BUG!还是用什么写什么比较好!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值