0

So I implemented a dataview and a list format card to display my json in store. I am trying to get the two view to share one store, since the data are the same. However the way i am doing it is not really working, if I only have Dataview or List it works fine. When I have both call the store, it will stop working... please help!

Dataview:

Ext.define('Sencha.view.hoardboard.HoardList', {
   extend: 'Ext.DataView',
   xtype: "hoardlist",
   requires: ['Ext.XTemplate'],
   config: {

                flex:1,
                scrollable: true,
                store: 'Plist',   
                baseCls: 'columns',

                itemTpl: '<div class=pin><img src={image}><div style="padding-top: 10px; padding-left: 20px; padding-right:20px">{name}<br>{brand}</div></div>'

   }
});

List view

Ext.define('Sencha.view.hoardboard.HoardList2', {
   extend: 'Ext.List',
   xtype: "hoardlist2",

   config: {
     flex:1,
     scrollable: true,
     store: 'Plist',   
     grouped: true,
     itemTpl: '{name}'
   }
});

Model

Ext.define('Sencha.model.HoardList', {
        extend: 'Ext.data.Model',
        config: {
            fields: [
                {
                    name: 'name',
                    type: 'string'
                }, 
                {
                    name: 'image',
                    type: 'string'
                },
                {
                    name: 'type',
                    type: 'string'
                },
                {
                    name: 'brand',
                    type: 'string'
                }
                , 
                {
                    name: 'color',
                    type: 'string'
                },
                 {
                    name: 'description',
                    type: 'string'
                }

            ]

        }
    });

Store

Ext.define('Sencha.store.HoardList',{
    extend: 'Ext.data.Store',
    storeId: 'Plist',
    model:'Sencha.model.HoardList',
    title: 'My Collection',
    autoLoad: true,
    sorters: 'name',
    grouper: {
        groupFn: function(record) {
            return record.get('name')[0];
        }
    },
    proxy: {
            type: 'ajax',
            url : 'products.json',
            reader: {type: 'json', rootProperty:'products'}

        }

});

Thank you so much!

4

1 回答 1

0

一般来说,当您使用 Sencha 框架时,您不会在多个可视控件之间共享一个存储对象。

如果您想在两个地方使用同一个商店,您需要克隆它并拥有两个单独的商店对象。

于 2013-06-08T04:35:21.273 回答