This issue duplicates another issue.
  1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    37
    Vote Rating
    2
    DonM is on a distinguished road

      0  

    Default [2.1] List's refresh() method does not re-render the itemTpl

    [2.1] List's refresh() method does not re-render the itemTpl


    REQUIRED INFORMATION
    Touch version tested:
    • Sencha Touch 2.1.0
    Browser versions tested against:
    • Safari 5.1.2
    • Chrome 23.0.1271.97
    Description:
    • When you use setItemTpl to change the template for a list, it will continue to show the old template even after calling refresh() on the list. The documentation for refresh() states that it "Refreshes the view by reloading the data from the store and re-rendering the template" but it doesn't seem to work that way. It seemed to work in Sencha Touch 2.0.1 and 1.1, but no longer works.
    Steps to reproduce the problem:
    • create a list with an initial template
    • set a new template using setItemTpl()
    • call refresh() on the list
    The result that was expected:
    • The new template should take effect.
    The result that occurs instead:
    • The old template continued to show up for the list.
    Test Case:
    Code:
            Ext.Viewport.add(
            {
                id: 'MainList',
                xtype: 'list',
                itemTpl: '{name}',
                store:
                {
                    fields: ['name', 'position'],
                    data: [
                            { name: 'Bob', position: 'Goalie' },
                            { name: 'Tom', position: 'Left Wing' },
                            { name: 'Ralph', position: 'Defense' }
                        ]
                },
                items:
                [
                    {
                        docked: 'top',
                        xtype: 'toolbar',
                        items:
                        [
                            {
                                xtype: 'button',
                                text: 'Update Template',
                                ui: 'accept',
                                handler: function ()
                                {
                                    this.up('list').setItemTpl('{position}');
                                    this.up('list').refresh();
                                }
                            }
                        ]
                    }
                ]
            });
    HELPFUL INFORMATION
    Operating System:
    • Windows Server 2003
    • Windows 7

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


    This was fixed for 2.1.1 (will be coming out in new couple weeks)

    http://www.sencha.com/forum/showthread.php?248221
    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
    Nov 2012
    Location
    London
    Posts
    19
    Vote Rating
    0
    alessio.valentini is on a distinguished road

      0  

    Default temp solution

    temp solution


    Hi,

    I am having the same exact problem and I have to go live by the end of Jen.

    Is there a temporary solution?

    When ST2.1.1 is going to be released otherwise?

  4. #4
    Sencha User
    Join Date
    Apr 2012
    Posts
    37
    Vote Rating
    2
    DonM is on a distinguished road

      0  

    Default


    Alexfluger posted a fix on http://www.sencha.com/forum/showthre...t-(v2.1)/page2
    but I haven't tried it personally.

    I haven't heard any updates on the 2.1.1 release date. It would be nice to get some news about it.

  5. #5
    Sencha User
    Join Date
    Apr 2011
    Posts
    134
    Vote Rating
    1
    stefankendall is an unknown quantity at this point

      0  

    Default


    If the template isn't dynamic, put all your templates in a single template toggled on and off by a class.

    itemTpl: new Ext.XTemplate("<div class='temp1'>...</div><div class='temp2'...")

    etc.