1. #1
    Ext User
    Join Date
    Oct 2008
    Posts
    91
    Vote Rating
    0
    Michi_de is on a distinguished road

      0  

    Default Grid Sort - Disabled by Controller-Event

    Grid Sort - Disabled by Controller-Event


    Hi,

    i've written an application which is using all the MVC classes from ext gwt.
    So after a button is clicked, an event is fired, the right controller takes this event and forward it to the right view.
    It works very good.

    But there is one problem:
    After initialization, the "showStatistics" event is fired. The controller forwards it to the "contentView". The content view just do one thing:

    Code:
    private void onShowStatistics(){
            LayoutContainer wrapper = (LayoutContainer) Registry.get("center");
            wrapper.removeAll();
            wrapper.add(statPanel);
            wrapper.layout();
        }
    the "statPanel" is a custom widged (extends: ContentPanel).
    So i take the "center" LayoutContainer and put the ContentPanel-Subclass into it.

    After this initial "showStatistics" event, the statistic panel is shown.
    The statistic panel contains a grid (paging grid with a store and toolbar binded).

    The grid is working very good. I see all the data and i can sort the data and page through the data.

    But now i hit a button, which fires again the "showStatistics" event. Now the same procedure take place.
    I still can see the grid and the data. But now every time i try to sort the values, it does the sort twice. It does sort it twice so fast, normaly i wouldnt even know it does. After i watched my log file, i saw it does the sort method twice.

    But why? If i click another time on the button, to fire the "showStatistics" event, it still just sort it twice.
    If i reload the application and the initial event fires the "showStatistics" event, everything works just fine till i do something, what fires "showStatistics" event one more time.

    My ContentView just do the code, i mentioned above. It just take the center, remove all and put the statisticsPanel inside. After it redo this job, the grid's sorting just don't work right anymore.

    Any Help?

  2. #2
    Ext User
    Join Date
    Oct 2008
    Posts
    91
    Vote Rating
    0
    Michi_de is on a distinguished road

      0  

    Default


    Maybe i didn't have been clear enough in my problem definition? Do you need more information or something, so you can understand my bug/problem better?
    Its some really not easy to find bug... as i tried to say, its just very strange. When i first fire the event, my panel with the grid inside gets displayed bug-free. Now i hit a button and the event is fired again, now i still see the panel with the grid but the sort is bugged. Everything is sorted twice (very fast, like the event is just fired twice for some reason).

    /edit:
    one more thing i found, which is bugged when i refired my event:
    i cant resize the rows anymore.

    What is the thing, which makes my panel-with-grid bugged? :/

  3. #3
    Ext GWT Premium Member gslender's Avatar
    Join Date
    Mar 2008
    Location
    Brisbane, Australia
    Posts
    1,572
    Vote Rating
    3
    gslender is on a distinguished road

      0  

    Default


    Very hard to say without seeing the full code. Try breaking the app into smaller bits and test each part individually to ensure each is working 100%.

  4. #4
    Ext User
    Join Date
    Oct 2008
    Posts
    91
    Vote Rating
    0
    Michi_de is on a distinguished road

      0  

    Default


    Well its realy not that much code, used after the event is fired.
    -hit button
    -event is fired
    -controller catch the event, use "forwardToView(view, event)"
    -the view procede the code i mentioned above

    thats it.

    Well here is my code for the ContentPanel, which is what i add into the "wrapper":
    see a picture of this widget below..
    Code:
    public class StatisticsPanel extends ContentPanel {
        
        private Grid<Statistic> buGrid , vhGrid;
        private ArrayList<ColumnConfig> buConfigs, vhConfigs;
        private ColumnConfig buColumn, vhColumn;
        private ColumnModel buColumnmodel, vhColumnModel;
        private Text buStatisticsHeader, vhStatisticsHeader;
        
        public StatisticsPanel (ListStore<Statistic> statisticStore, ListStore<Statistic> statVHStore) {
            
            setBodyBorder(true);   
            setFrame(true); 
            setHeading("Statistics");   
            setButtonAlign(HorizontalAlignment.CENTER);   
            setLayout(new FlowLayout());
            setSize((Integer)Registry.get("AppWidth"),450);
                    
            buConfigs = new ArrayList<ColumnConfig>();
              
              buColumn = new ColumnConfig();
            buColumn.setId("name");
            buColumn.setHeader("Business Unit");
            buColumn.setWidth(25);
            buConfigs.add(buColumn);
            
            buColumn = new ColumnConfig();
            buColumn.setId("counter");
            buColumn.setHeader("Quantity");
            buColumn.setWidth(50);
            buConfigs.add(buColumn);
            
            buColumnmodel = new ColumnModel(buConfigs);
            
            buGrid = new Grid<Statistic>(statisticStore, buColumnmodel);   
            buGrid.setStyleAttribute("borderTop", "none");   
            buGrid.setHeight(200);
            buGrid.setAutoExpandColumn("name");   
            buGrid.setBorders(true);
            
            buGrid.addListener(Events.CellDoubleClick, new Listener<GridEvent>(){              
                public void handleEvent(GridEvent be) {
                    Dispatcher.get().dispatch(AppEvents.BUSearch);                
                }
            });    
            
            vhConfigs = new ArrayList<ColumnConfig>();
              
              vhColumn = new ColumnConfig();
            vhColumn.setId("name");
            vhColumn.setHeader("Virtual Host");
            vhColumn.setWidth(210);
            vhConfigs.add(vhColumn);
            
            vhColumn = new ColumnConfig();
            vhColumn.setId("counter");
            vhColumn.setHeader("Quantity");
            vhColumn.setWidth(50);
            vhConfigs.add(vhColumn);
            
            vhColumnModel = new ColumnModel(vhConfigs);
            
            vhGrid = new Grid<Statistic>(statVHStore, vhColumnModel);   
            vhGrid.setStyleAttribute("borderTop", "none");   
            vhGrid.setHeight(200);
            vhGrid.setAutoExpandColumn("name");   
            vhGrid.setBorders(true);
            
            vhGrid.addListener(Events.CellDoubleClick, new Listener<GridEvent>(){              
                public void handleEvent(GridEvent be) {
                    Dispatcher.get().dispatch(AppEvents.VHSearch);                
                }
            });
            
            buStatisticsHeader = new Text("Shortcuts by Business Units");
            vhStatisticsHeader = new Text("Shortcuts by Virtual Hosts");
                    
            add(buStatisticsHeader);
            add(buGrid);
            add(vhStatisticsHeader);
            add(vhGrid);
        }
    Attached Images

  5. #5
    Ext User
    Join Date
    Oct 2008
    Posts
    91
    Vote Rating
    0
    Michi_de is on a distinguished road

      0  

    Default


    Here is more code, maybe this helps?
    Everytime the sort event is fired, the store gets reloaded, this is what my servlet does to get the store loaded:

    The sort thingy is pretty much the same i saw in the gxt mail example... is here any bug?

    Code:
    public PagingLoadResult<Statistic> getBUStatistics(PagingLoadConfig config) {
            DBQuery query = new DBQuery();
            List<Statistic> statList = query.getBUStatisticList();
            
            if (config.getSortInfo().getSortField() != null) {
                final String sortField = config.getSortInfo().getSortField();
                if (sortField != null) {
                  Collections.sort(statList, config.getSortInfo().getSortDir().comparator(new Comparator<Object>() {
                    public int compare(Object o1, Object o2) {
                      Statistic p1 = (Statistic) o1;
                      Statistic p2 = (Statistic) o2;
                      if (sortField.equals("name")) {
                        return p1.getName().compareTo(p2.getName());
                      } else if (sortField.equals("counter")) {
                        return ((Integer)p1.getCounter()).compareTo((Integer)(p2.getCounter()));
                      }
                      return 0;
                    }
                  }));
                }
              }
            ArrayList<Statistic> sublist = new ArrayList<Statistic>();
              int start = config.getOffset();
              int limit = statList.size();
              if (config.getLimit() > 0) {
                limit = Math.min(start + config.getLimit(), limit);
              }
              for (int i = config.getOffset(); i < limit; i++) {
                sublist.add(statList.get(i));
              }
              return new BasePagingLoadResult<Statistic>(sublist, config.getOffset(), statList.size());
        }

  6. #6
    Ext User
    Join Date
    Oct 2008
    Posts
    91
    Vote Rating
    0
    Michi_de is on a distinguished road

      0  

    Default


    And this is how my store list is binded (initialize() method in controller)
    Code:
    statStoreProxy = new RpcProxy() {
                @Override
                public void load(Object loadConfig, AsyncCallback callback) {   
                       service.getBUStatistics((PagingLoadConfig) loadConfig, callback);      
                     }
            };
            statStoreLoader = new BasePagingLoader(statStoreProxy);
            statStoreLoader.setRemoteSort(true);
            statStoreLoader.load();
            statStore = new ListStore<Statistic>(statStoreLoader);
    So this is all the code i can imagine, what is related to this problem. Nobody see any false statement or sthg? Any bug? Any failure in my coding? =C

  7. #7
    Ext GWT Premium Member gslender's Avatar
    Join Date
    Mar 2008
    Location
    Brisbane, Australia
    Posts
    1,572
    Vote Rating
    3
    gslender is on a distinguished road

      0  

    Default


    I don't understand what bit isn't working... reading through everything you've given and said, it isn't clear what exactly is the problem. You mention clicking a button, but there is no button in your code. Are you talking about double-clicking the cells? in which case where is the event code that is being executed???

    Please take the time to explain yourself better.

  8. #8
    Ext User
    Join Date
    Oct 2008
    Posts
    91
    Vote Rating
    0
    Michi_de is on a distinguished road

      0  

    Default


    Ok, this is how my application works:

    I load the application, the controllers and views get initialized. The stores i need get loaded (one of them is the statisticsStore, the code is mentioned above - the rpc proxy code). Then the views get initialized, which initial all the widgets i need. For example the statistics Panel widged (code mentioned above). The statistics Panel constructor get the store data.

    After the initialisation of my application, the "showStatistics" event is fired.

    Now the controller gets the event and forward it to the "content view". The content view wrapps the center, remove all widgets which are actually in the center and put the statistics Panel widget inside. (code mentioned above - the wrapper code in the first posting)

    Now my application is stable. I see the statistics panel with my data i want it to show. I can click on any column in order to sort by this value. It works fine.

    Now there is a button in my application. This button is in the "header panel" widget. I click on this button. The "show Statistics" event is fired again.

    Now the same procedure starts, as mentioned above. Actually: i again get my center cleaned by all widgets (the wrapper code in the initial code) and then put the statistics panel into the wrapper.

    Now i will see the statistics panel again. But when i click on any column, in order to sort, the sort does not work propper anymore. It just make the sorting twice. If its a int column, it will first sort it by low to high and then high to low just one sort after each other. It sorts so fast, i dont see any change in my statistics panel. But when i take a look into my log file, i see that the servlets method is used twice (see the sort code above).
    I also cant resize the columns width anymore.

    If its not in hosted mode, i can click on the web browsers "reload" button and the application is loaded a new. Now the statistics works again, because the application got completely reloaded and initialized by new. Now its just the same as above: when i click on the button in the header, to fire the "show statistics" event, the statistics grid will be broken again.

    Hope this was clear enough?

  9. #9
    Ext GWT Premium Member gslender's Avatar
    Join Date
    Mar 2008
    Location
    Brisbane, Australia
    Posts
    1,572
    Vote Rating
    3
    gslender is on a distinguished road

      0  

    Default


    the original gird is not unloaded from the store.... call grid.reconfigure(null) to ensure the old grid is unbound from the store... the reload/sort etc might be messing things up.

  10. #10
    Ext User
    Join Date
    Oct 2008
    Posts
    91
    Vote Rating
    0
    Michi_de is on a distinguished road

      0  

    Default


    After i click the "show statistics"-button, the grid is not initialized again. The statistics panel widged instance is just put out of the wrapper (wrapper.removeAll() ) and then put again into the wrapper (wrapper.add(statPanel)).
    The store, which is bind to the grid inside the statPanel, is just being reloaded again and again (statLoader.load()).

    You see?
    Code:
    statStoreProxy = new RpcProxy() {
                @Override
                public void load(Object loadConfig, AsyncCallback callback) {   
                       service.getBUStatistics((PagingLoadConfig) loadConfig, callback);      
                     }
            };
            statStoreLoader = new BasePagingLoader(statStoreProxy);
            statStoreLoader.setRemoteSort(true);
            statStoreLoader.load();
            statStore = new ListStore<Statistic>(statStoreLoader);
    the statStore i give my statistic panel widget in my intialize() method. This method is only used once: in the initialization.
    When the show statistics event is fired, i just get the stat panel and put it into the center layoutcontainer (wrapper) and thats it.

    So how i should unbind the store, everytime i put my statistics panel into "foreground"?

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