后台json数据加载到grid的store中

//页面弹窗

var win = new Ext.Window({
            layout:'fit',
            width:1020,
            height:600,
            closeAction:'hide',
            items:[confirm],//在弹窗中嵌套表格;
            modal:true,
            listeners : {
                 'hide':function(){
                     store.reload();
                 },
                    'show':function(){
                 }
             },
            buttons:[
                {
                    text:'确认',
                    handler:function(){
                    }
                },{
                    text:'取消',
                    handler:function(){
                        win.hide();
                    }
                }]
        });

//设定grid格式

var confirm = new Ext.grid.GridPanel({
            store:personStore,
            columns:[
                {header:"商品编号",dataIndex:"Meta_productNo",width :100,align:'left',resizable:true,sortable:true },
                {header:"商品名称",dataIndex:"Meta_productName",width :100,align:'left',resizable:true,sortable:true },
                {header:"商品属性",dataIndex:"Meta_attribute",width :100,align:'left',resizable:true,sortable:true },
                {header:"SKU编号",dataIndex:"Meta_sku",width :100,align:'left',resizable:true,sortable:true },
                {header:"SKU颜色",dataIndex:"Meta_color",width :100,align:'left',resizable:true,sortable:true },
                {header:"SKU规格",dataIndex:"Meta_standard",width :100,align:'left',resizable:true,sortable:true },
                {header:"进货价(元)",dataIndex:"Meta_buyingPrice",width :100,align:'left',resizable:true,sortable:true},
                {header:"批发价(元)",dataIndex:"Meta_tradePrice",width :100,align:'left',resizable:true,sortable:true },
                {header:"零售价(元)",dataIndex:"Meta_retaillPrice",width :100,align:'left',resizable:true,sortable:true },
                {header:"平台评估价(元)",dataIndex:"Meta_appraisePrice",width :100,align:'left',resizable:true,sortable:true },
            ],
            layout:'fit'
        });

//设定JsonStore

var personStore = new Ext.data.JsonStore({
            method : "POST",
            fields : ["Meta_productNo","Meta_productName","Meta_attribute","Meta_sku","Meta_color","Meta_standard","Meta_buyingPrice","Meta_tradePrice","Meta_retaillPrice","Meta_appraisePrice"]        //与Grid1列一致,至少列名称一致
        });

//重头戏=======加载后台json数据弹窗展示

var data = Ext.util.JSON.decode(response.responseText);
personStore.loadData(data);
win.show();

//后台的json格式直接返回跟JsonStore中的格式一样,无需前缀,例如:

[{"Meta_productNo":"20012111","Meta_productName":"凯旋1664 360全网通","Meta_attribute":"全网通","Meta_sku":"200121113344","Meta_color":"红色","Meta_standard":"8G-64G","Meta_buyingPrice":"0.000000","Meta_tradePrice":"0.000000","Meta_retaillPrice":"0.000000","Meta_appraisePrice":"0.000000"}]

转载于:https://my.oschina.net/u/4048873/blog/3069960

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值