1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    11
    Vote Rating
    0
    lucas.mouilleron@me.com is on a distinguished road

      0  

    Default Unanswered: dataview with component not refreshing when store is reloaded

    Unanswered: dataview with component not refreshing when store is reloaded


    When i update my store (i traced in the console that the store is really updated), my dataview.dataview items update just one time.
    The second time i press my refresh button, the do not update.

    I noticed the updateContainerPanel is not called after the first load.

    (Hint, if i don't have an 'id' field in my model, the items are added after the existing ones. If i have an 'id' field, they are not updated.)

    Thx a lot for your help !

    Code:
    //----------------------------------------------------------------------
    Ext.define('ts.view.jobListItem', {
        extend: 'Ext.dataview.component.DataItem',
        xtype: 'jobListItem',
    
    
        config: {
    	containerPanel: true
        },
    
    
        applyContainerPanel: function(config) {
    	return Ext.factory(config, Ext.Panel, this.getContainerPanel());
        },
    
    
        updateContainerPanel: function(newContainerPanel, oldContainerPanel) {
    	if (oldContainerPanel) {
    	    this.remove(oldContainerPanel);
    	}
    
    
    	if (newContainerPanel) {
    	    var record = this.getRecord();
    	    
    	    newContainerPanel.setLayout({
    		type: 'vbox',
    		align: 'center'
    	    });
    	    
    	    var jobId = new Ext.Label();
    	    jobId.setHtml(record.get('id'));
    	    jobId.addCls('jobItemTitle');
    	    newContainerPanel.add(jobId);
    	    this.add(newContainerPanel);
    	}
        }
    });
    
    
    
    
    //----------------------------------------------------------------------
    Ext.define('ts.views.jobs', {
        extend: 'Ext.Panel',
        config:{	
    	title:'Jobs',
    	layout:'fit'
        },
        
        initialize: function() {
    	this.callParent();
    	var store = Ext.create('ts.store.jobsStore');
    	var jobsList = Ext.create('Ext.DataView', {
    	    disableSelection:true,
    	    plugins: [
    	    {
    		xclass: 'Ext.plugin.PullRefresh',
    		pullRefreshText: 'Update jobs'
    	    }
    	    ]
    	    ,
    	    store: store,
    	    useComponents: true,
    	    defaultType: 'jobListItem'
    	});
    	
    	
    	var refreshButton = Ext.create('Ext.Button', {
    	    text: 'Refresh jobs',
    	    handler: function(button, e) {
    		store.load();
    		jobsList.refresh();
    		console.log('refresh');		
    	    }
    	});
    	   
    	refreshButton.setDocked('top');
    	refreshButton.setIconCls('refresh');
    	this.add(refreshButton);
    	this.add([jobsList]);
        }
    });

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,073
    Answers
    3500
    Vote Rating
    854
    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

      0  

    Default


    What ST2 version are you using?
    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.

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    11
    Vote Rating
    0
    lucas.mouilleron@me.com is on a distinguished road

      0  

    Default my version

    my version


    2.0.0.RC

  4. #4
    Sencha User
    Join Date
    Feb 2012
    Posts
    11
    Vote Rating
    0
    lucas.mouilleron@me.com is on a distinguished road

      0  

    Default


    any ideas ?

  5. #5
    Sencha Premium Member
    Join Date
    Apr 2012
    Posts
    27
    Answers
    1
    Vote Rating
    0
    montymccune is on a distinguished road

      0  

    Default Having the same problem...

    Having the same problem...


    Any thoughts yet?

  6. #6
    Sencha User bluehipy's Avatar
    Join Date
    Mar 2010
    Location
    Romania
    Posts
    606
    Answers
    66
    Vote Rating
    26
    bluehipy will become famous soon enough bluehipy will become famous soon enough

      0  

    Default


    Show us the store`s model definition.

    Hint: id field is used by default as primary key by model unless you specified other way.

  7. #7
    Sencha Premium Member
    Join Date
    Apr 2012
    Posts
    27
    Answers
    1
    Vote Rating
    0
    montymccune is on a distinguished road

      0  

    Default Some details...

    Some details...


    Quote Originally Posted by bluehipy View Post
    Show us the store`s model definition.

    Hint: id field is used by default as primary key by model unless you specified other way.
    Here is my model...

    Code:
    Ext.define('PhoenixTouch.model.Orders',{
        extend: 'Ext.data.Model',
    
    
        requires:'Ext.DateExtras',
    
    
        xtype: 'ordersModel',
    
    
        config: {
            fields: [
                {name: 'DateCollect', type: 'DATE', dateFormat: 'MS'},
                {name: 'PatientID', type: 'STRING'},
                {name: 'ProviderID', type: 'INT'},
                {name: 'UserID', type: 'INT'},
                {name: 'TestOrdered', type: 'STRING'},
                {name: 'Type', type: 'STRING'},
                {name: 'LabReqID', type: 'INT'},
                {name: 'CptCode', type: 'STRING'},
                {name: 'Modifier', type: 'STRING'},
                {name: 'OrdResults', type: 'STRING'},
                {name: 'Code', type: 'STRING'},
                {name: 'OrderStatus', type: 'STRING'},
                ]
        }
    });
    Here is my dataItem...

    Code:
            dataMap: {
    
    
                getDescription: {
                    setHtml: 'CptCode'
                }
            },
    
    
            cls: 'orderTabBar-data-item',
    
    
            description:{
    
    
            },
    
    
            layout: {
                type: 'hbox'
            }
        },
    
    
        applyDescription: function(config) {
            return Ext.factory(config, Ext.Component, this.getDescription());
        },
    
    
        updateDescription: function(newDesc) {
            if (newDesc) {
                this.add(newDesc);
            }
        },


    Apply and Update are only called the first time I load the dataview. I have even tried to call Refresh from my controller. Another question - is it possible to dynamically set the DataMapped values? Example: if I wanted to change...

    Code:
            dataMap: {
    
    
                getDescription: {
                    setHtml: 'CptCode'
                }
            },

    to...

    Code:
            dataMap: {
    
    
                getDescription: {
                    setHtml: 'CptDescription'
                }
            },

    thanks,
    Monty

  8. #8
    Sencha - Community Support Team edspencer's Avatar
    Join Date
    Jan 2009
    Location
    Palo Alto, California
    Posts
    1,939
    Answers
    29
    Vote Rating
    9
    edspencer is a jewel in the rough edspencer is a jewel in the rough edspencer is a jewel in the rough

      0  

    Default


    You should definitely use the GA release instead of any of the RC builds as a good number of issues were addressed between those releases
    Ext JS Senior Software Architect
    Personal Blog: http://edspencer.net
    Twitter: http://twitter.com/edspencer
    Github: http://github.com/edspencer