1. #1
    Ext User
    Join Date
    Jul 2008
    Posts
    202
    Vote Rating
    0
    eugenparaschiv is on a distinguished road

      0  

    Default Dynamic addition to a list store

    Dynamic addition to a list store


    I have found a bug when adding elements to a list store. The bug is also submitted here:
    http://extjs.com/forum/showthread.php?t=67443

    I'm having problems adding elements dynamically to a list; I'm using a simple ListView and I want to be able to add more items to it after render.
    Just to go a little into details - I'm looking at the addition flow:
    FIRST ADD CALL (store.add( firstModel )
    - the item gets added into the store of the ListView
    - the StoreListener (of the ListView) gets triggered
    - the onAdd method (from ListView) gets called (but it seems not to actually add the item the the 'all' field (which ends up with size 0 after the addition))
    - done
    SECOND ADD CALL
    - the call now fails in the onAdd method (ListView) - actually in the ArrayList.addAll method which gets called with wrong arguments

    The code:
    Code:
    public class DnukHome implements EntryPoint{
        public void onModuleLoad(){
            final RootPanel rootPanel = RootPanel.get();
            final LayoutContainer lc = new LayoutContainer();
            lc.setWidth( 700 );
            lc.setLayout( new RowLayout( Orientation.VERTICAL ) );
            rootPanel.add( lc );
            
            // create a simple model
            final BaseModel firstModel = new BaseModel();
            firstModel.set( "author", "Current User" );
            firstModel.set( "date", "May 04, 2009" );
            firstModel.set( "text", "sample text" );
            
            // create, configure and add the list
            final ListStore< BaseModel > store = new ListStore< BaseModel >();
            final ListView< BaseModel > list = new ListView< BaseModel >( store );
            list.setSelectionModel( null );
            list.setTemplate( this.createTemplate() );
            
            store.add( firstModel );
            store.add( firstModel ); // this fails
            
            lc.add( list );
            
        }
        
        private final native String createTemplate() /*-{
        return [
            '<tpl for=".">',
                '<div>',
                    '<span><a href="#"><b>{author}</b></a></span> <span>- {date}</span>',
                    '<p>{text}</p>',
                '</div>',
            '</tpl>'].join("");
        }-*/;
    }
    Details aside, am I doing something wrong?

  2. #2
    Ext User
    Join Date
    Nov 2008
    Posts
    2
    Vote Rating
    0
    MihaiMese is on a distinguished road

      0  

    Default Dynamic addition to a list store

    Dynamic addition to a list store


    I would also like to know the answer to this as I need to dynamically add models to a store, in a ListView, so if someone knows how to solve this, a solution would be much appreciated.

  3. #3
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    There is an issue in your code.

    Code:
    list.setItemSelector("div");

  4. #4
    Ext User
    Join Date
    Jul 2008
    Posts
    202
    Vote Rating
    0
    eugenparaschiv is on a distinguished road

      0  

    Default


    Cool fix, I have to say.
    Can you please explain why the default value was no good and what this one does?
    Thanks for the solution.
    Eugen.

  5. #5
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    Your template uses "div" is itemSelector. So you have to set it.

Thread Participants: 2

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