var dataFromServer=[['132343433','剃须刀','PHILIPS-XP5'],['4354554545','戒指','中国黄金']];        /////////////Field definition///////////////////////////
        var barcode=new Ext.data.Field({
            //allowBlank:false,
            mapping:0,
            //sortDir:'ASC',
            type:Ext.data.Types.STRING,
            name:'barcode'
        });
        var productName=new Ext.data.Field({
            //allowBlank:false,
            mapping:1,
            //sortDir:'ASC',
            type:Ext.data.Types.STRING,
            name:'produtName'
        })
        var productType=new Ext.data.Field({
            //allowBlank:false,
            mapping:2,
            //sortDir:'ASC',
            type:Ext.data.Types.STRING,
            name:'productType'
        })
        /////////////Record definition////////////////////
        var record=new Ext.data.Record.create([Ext.data.Record.id,barcode,productName,productType]);
        ////////////////////////////////////////
        var reader=new Ext.data.ArrayReader({
            idIndex:0
        },record);
        ///////////Proxy definition//////////////////////////////
        var agent=new Ext.data.MemoryProxy(dataFromServer);        //////////////Store definition///////////////////
        var store=new Ext.data.ArrayStore({
            //data:dataFromServer,
            reader:reader,
            //url:'',
            proxy:agent,
            storeId:'myStore,',
            autoLoad:true
        });
               store.load(dataFromServer);
        /////////////////Display in browser///////////////////////
        this.grid=new Ext.grid.GridPanel({
            store:store,
            colModel:new Ext.grid.ColumnModel({
                defaults:{
                    width:120
                    //sortable:true
                },
                columns:[
                    //{header:'记录号',width:100,dataIndex:0},
                    {header:'条形码',width:100,dataIndex:'barocode'},
                    {header:'产品名',width:100,dataIndex:'productName'},
                    {header:'产品型号',width:100,dataIndex:'productType'}
                ],
            viewConfig:{
                forceFit:true
            },
            sm:new Ext.grid.RowSelectionModel({
                singleSelect:true            })
        }),
            width:667,
            height:400,
            title:'你所搜索到的产品',
            //region:'south',
            autoShow:true
        });
为什么不显示数据,只显示标题

解决方案 »

  1.   


    var store = new Ext.data.ArrayStore({
        storeId: 'myStore',
        idIndex: 0,  
        fields: [
           'barcode','productName','productType']
    });
    store.load(dataFromServer);
      

  2.   

    我用的是3.3.0   ArrayStore必须要指定proxy,否则出现错误
      

  3.   

    加上proxy可行,然后修改成你这样的代码,但是按照我的思路为什么不行呢ps:我修改了record如下原来的:
    var record=new Ext.data.Record.create([Ext.data.Record.id,barcode,productName,productType]);
    现在的:
    var record=new Ext.data.Record.create([barcode,productName,productType]);