Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #1
    Ext GWT Premium Member
    Join Date
    Feb 2010
    Location
    Cracow, Poland
    Posts
    15
    Vote Rating
    0
    lhanusiak is on a distinguished road

      0  

    Question Grid sorting problem [GXT 2.1.1 with GWT 1.7.1]

    Grid sorting problem [GXT 2.1.1 with GWT 1.7.1]


    In my application I use grid with store data loaded by RPC proxy.
    Code:
    private final BeanModelReader beanReader = new BeanModelReader();
    private final UserProxy proxy = new UserProxy();
    private final BaseListLoader<ListLoadResult<BeanModel>> loader = new BaseListLoader<ListLoadResult<BeanModel>>(proxy, beanReader);
    private final ListStore<BeanModel> store = new ListStore<BeanModel>(loader);
    private final Grid<BeanModel> browser = new Grid<BeanModel>(store, createUserColumnModel());
    
    private class UserProxy extends RpcProxy<List<ApplicationUserDTO>> {
    		private Department department;
    
    		@Override
    		protected void load(Object loadConfig, AsyncCallback<List<ApplicationUserDTO>> callback) {
    			userService.getADUserList(department, callback);
    		}
    
    		public void setDepartment (Department department) {
    			this.department= department;
    		}
    	}
    Because loaded data have to be sorted by selected column I tried
    Code:
    browser.getStore().setDefaultSort("lastname", SortDir.ASC);
    and... it doesn't worked. So I started to dig in GXT source code and found
    Code:
    public class ListStore<M extends ModelData> extends Store<M> {
     ...
         @SuppressWarnings("unchecked")
         protected void onLoad(LoadEvent le) {
            ...
            if (storeSorter != null) {
                 applySort(true);
            }
            ...
         }
     ...
    }
    Full of hope I added following line ...
    Code:
    browser.getStore().setStoreSorter(new StoreSorter<BeanModel>(StoreSorter.DEFAULT_COMPARATOR));
    but as I soon realized, grid doesn't sort data at all. It has sorting indicator visible but data are displayed in totally random order.

    After further reading I found ...
    Code:
    public class ListStore<M extends ModelData> extends Store<M> {
     ...
         @SuppressWarnings("unchecked")
         protected void onLoad(LoadEvent le) {
            ...
            if (le.<Object> getConfig() instanceof ListLoadConfig) {
             ListLoadConfig config = le.getConfig();
             if (!Util.isEmptyString(config.getSortInfo().getSortField())) {
              sortInfo = config.getSortInfo();
             } else {
              sortInfo = new SortInfo();
             }
            }
            ...
         }
     ...
    }
    ... and finally added...
    Code:
    loader.setSortField("lastname");
    loader.setSortDir(SortDir.ASC);
    loader.setReuseLoadConfig(true);
    Form this moment grid sorting worked just fine.

    I would like to know if is there any easier way to sort data in grid than adding all of the following lines every time
    Code:
    browser.getStore().setDefaultSort("lastname", SortDir.ASC);
    loader.setSortField("lastname");
    loader.setSortDir(SortDir.ASC);
    loader.setReuseLoadConfig(true);
    store.setStoreSorter(new StoreSorter<BeanModel>(StoreSorter.DEFAULT_COMPARATOR));
    Thanks in advance.

    P.S. Sorry for my English, I am still learning.

  2. #2
    Ext User
    Join Date
    Mar 2007
    Posts
    2
    Vote Rating
    0
    stburns is on a distinguished road

      0  

    Default


    Try setting sort info in loaderConfig passed to proxy load method

Thread Participants: 1