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?