1. #1
    Sencha User
    Join Date
    Jun 2012
    Posts
    6
    Vote Rating
    1
    nicanor.gutierrez is on a distinguished road

      0  

    Default Answered: Dataview duplicating records

    Answered: Dataview duplicating records


    Hello, I am using ExtJS 4.1.1a GPL and my application is using the MVC pattern.

    Background: I have a some tab panels with grids inside them. I also have one dataview which is shown in some of the tab panels. (My code is at the end of the message)

    Problem: When I include the dataview just in one of the tab panels, it works fine, but if I use it in more than one tab panels, it duplicates the records in the dataview, although if I look in the store there are the right number of records.

    This is the result when the dataview is referenced just in two tabs :

    categories_bad.png

    This is the result when the dataview is referenced just in one tab :

    categories_fine.png

    Any idea about what I'm doing wong?


    I have created the following dataview:

    Code:
    Ext.define('MyApp.view.CategoriesList', {
        extend : 'Ext.panel.Panel',
        alias : 'widget.categorieslist',
        animCollapse : true,
        region : 'west',
        width : 200,
        layout : 'fit',
        title : 'Categories,
        items : [{
                    xtype : 'dataview',
                    store : 'Categories',
                    autoScroll : true,
                    selModel : {
                        mode : 'SINGLE'
                    },
                    trackOver : true,
                    cls : 'category-list',
                    itemSelector : 'category-list-item',
                    overItemCls : 'category-list-item-hover',
                    tpl : '<tpl for="."><div class="category-list-item">{name}</div></tpl>'
                }]
    });
    I reference this dataview in two tab panels, as you can see in this viewport:

    Code:
    Ext.define('MyApp.view.Viewport', {
        extend : 'Ext.container.Viewport',
        layout : 'border',
        alias : 'widget.viewport',
        requires : ['MyApp.view.Products', 'MyApp.view.CategoriesList', 'MyApp.view.Places'],
    
        initComponent : function() {
            this.items = [Ext.createWidget('tabpanel', {
                                region : 'center',
                                width : 450,
                                id : 'tabPanel',
                                activeTab : 0,
                                defaults : {
                                    bodyPadding : 10
                                },
                                items : [{    
                                            title : 'Products',
                                            id : 'tabProducts',
                                            layout : {
                                                type : 'border'
                                            },
                                            defaults : {
                                                split : true
                                            },
                                            items : [{
                                                        xtype : 'categorieslist',
                                                        region:'west'
                                                    }, {
                                                        xtype : 'products',
                                                        region:'center'
                                                    }]
                                        }, { 
                                            title : 'Places',
                                            id : 'tabPlaces',
                                            layout : {
                                                type : 'border'
                                            },
                                            defaults : {
                                                split : true
                                            },
                                            items : [{
                                                        xtype : 'categorieslist',
                                                        region:'west'
                                                    }, {
                                                        xtype : 'places',
                                                        region:'center'
                                                    }]
                                        }, ]
                            })];
            this.callParent();
        }
    });
    I also have another two views. Their aliases are 'places' and 'products', but I think that their code is not important fot this problem.

    The model and store are:
    Code:
    Ext.define('MyApp.model.Category', {
                extend : 'Ext.data.Model',
                idProperty : '_id',
                fields : [{
                            name : '_id',
                            type : 'string'
                        }, {
                            name : 'name',
                            type : 'string'
                        }, ],
                proxy : {
                    type : 'memory,
                    reader : {
                        type : 'json'
                    }
                }
            });
    
    Ext.define('MyApp.store.crud.Categories', {
                extend : 'Ext.data.Store',
                requires : 'MyApp.model.Category',
                model : 'MyApp.model.Category'
            });
    and the JSON that fills the store:

    Code:
    [{
            "name": "Category One",
            "_id": "16d9f0b7ff0ffe2f202ff55e9700984f"
        }, {
            "name": "Category Two",
            "_id": "16d9f0b7ff0ffe2f202ff55e9700a5bb"
        }
    ]

  2. Is there anything loading the store with more data? If you are sharing a store in 2 views then if you make a change in one view to add/remove/sort/filter/etc the store then the other view will reflect the change.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Answers
    3462
    Vote Rating
    828
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      1  

    Default


    Is there anything loading the store with more data? If you are sharing a store in 2 views then if you make a change in one view to add/remove/sort/filter/etc the store then the other view will reflect the change.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Jun 2012
    Posts
    6
    Vote Rating
    1
    nicanor.gutierrez is on a distinguished road

      1  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    Is there anything loading the store with more data? If you are sharing a store in 2 views then if you make a change in one view to add/remove/sort/filter/etc the store then the other view will reflect the change.
    I guess that I was loading it twice somewhere in the controller, but I was unable to find where it was happening. Anyway, now it is working correctly so I suppose that I removed the part that was causing the problem.

    Thanks for your help.

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi