1. #1
    Ext User
    Join Date
    Jun 2008
    Location
    Hong Kong, China
    Posts
    29
    Vote Rating
    0
    ashleywong is on a distinguished road

      0  

    Default [CLOSED] Bug in LoadListener

    [CLOSED] Bug in LoadListener


    I am going to implements a data list which received data from a RPC call. On the loaderLoad method, I wish to pre-select some fields.

    However, I found that the loaderLoad() method is not really fired after the loader had loaded the data.

    Code:
    public class DataListStorePage extends LayoutContainer implements EntryPoint {
    
        public void onModuleLoad() {
            RootPanel.get().add(this);
        }
    
        @Override
        protected void onRender(Element parent, int pos) {
            super.onRender(parent, pos);
    
            setLayout(new FlowLayout(10));
    
            final DataList list = new DataList();
            list.setSelectionMode(SelectionMode.MULTI);
            list.setFlatStyle(true);
    
            RpcProxy proxy = new RpcProxy() {
    
                @Override
                protected void load(Object loadConfig, AsyncCallback callback) {
                    callback.onSuccess(TestData.getStocks());
                }
    
            };
            final BaseListLoader loader = new BaseListLoader(proxy);
            loader.addLoadListener(new LoadListener() {
    
                @Override
                public void loaderLoad(LoadEvent le) {
                    Window.alert(list.getItemCount() + "");
                }
    
            });
    
            final ListStore<Stock> store = new ListStore<Stock>(loader);
    
            DataListBinder<Stock> binder = new DataListBinder<Stock>(list, store);
            binder.setDisplayProperty("name");
            binder.init();
    
            ContentPanel panel = new ContentPanel();
            panel.setFrame(true);
            panel.setCollapsible(true);
            panel.setAnimCollapse(false);
            panel.setButtonAlign(HorizontalAlignment.CENTER);
            panel.setIconStyle("icon-list");
            panel.setHeading("Store DataList");
            panel.setLayout(new FitLayout());
            panel.add(list);
            panel.setSize(230, 250);
    
            ToolBar toolBar = new ToolBar();
    
            final StoreFilter<Stock> filter = new StoreFilter<Stock>() {
                public boolean select(Store store, Stock parent, Stock item,
                        String property) {
                    if (item.getName().charAt(0) == 'A') {
                        return false;
                    }
                    return true;
                }
            };
            store.addFilter(filter);
    
            TextToolItem sort = new TextToolItem("Sort");
            sort.setIconStyle("my-icon-asc");
            sort.addSelectionListener(new SelectionListener() {
                public void componentSelected(ComponentEvent ce) {
                    store.sort("name", SortDir.ASC);
                }
            });
    
            final ToggleToolItem filterItem = new ToggleToolItem("Filter A's");
            filterItem.setIconStyle("icon-filter");
            filterItem.addSelectionListener(new SelectionListener() {
                public void componentSelected(ComponentEvent ce) {
                    if (filterItem.isPressed()) {
                        store.applyFilters("name");
                    } else {
                        store.clearFilters();
                    }
    
                }
            });
            toolBar.add(sort);
            toolBar.add(new SeparatorToolItem());
            toolBar.add(filterItem);
            panel.setTopComponent(toolBar);
    
            add(panel);
    
            DeferredCommand.addCommand(new Command() {
    
                public void execute() {
                    loader.load();
                }
    
            });
        }
    }

  2. #2
    Sencha - GXT Dev Team darrellmeyer's Avatar
    Join Date
    May 2007
    Location
    Washington, DC
    Posts
    2,242
    Vote Rating
    2
    darrellmeyer is on a distinguished road

      0  

    Default


    It is fired after the load event, but before the list has responded to the event. You should be checking the data in the event:

    Code:
        loader.addLoadListener(new LoadListener() {
          @Override
          public void loaderLoad(LoadEvent le) {
            Window.alert("count: " + ((List)le.data).size());
          }
        });
    If you add your listener after you create the store, your code will work as the stores listener will be executed before yours.

  3. #3
    Ext User
    Join Date
    Jun 2008
    Location
    Hong Kong, China
    Posts
    29
    Vote Rating
    0
    ashleywong is on a distinguished road

      0  

    Default


    Thanks for advance.

    Actually, I want to pick up some entries to pre-select. However, le.getData() can only get the List<Stock>. How do I get the DataListItem?

    Attached is the available select method of DataList.
    Attached Images

  4. #4
    Ext User
    Join Date
    Jun 2008
    Location
    Hong Kong, China
    Posts
    29
    Vote Rating
    0
    ashleywong is on a distinguished road

      0  

    Default


    Quote Originally Posted by darrellmeyer View Post
    If you add your listener after you create the store, your code will work as the stores listener will be executed before yours.
    Sorry, I got it. Thanks

Thread Participants: 1

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