1

I need to customized the header sorting result of one column using GXT Local Pagination (PagingModelMemoryProxy). Here is my code:

PagingModelMemoryProxy proxy = new PagingModelMemoryProxy(data) {
        @Override
        public void load(DataReader<PagingLoadResult<? extends ModelData>> reader, Object loadConfig,
                AsyncCallback<PagingLoadResult<? extends ModelData>> callback) {
            if (loadConfig instanceof PagingLoadConfig) {
                PagingLoadConfig pagingConfig = (PagingLoadConfig) loadConfig;

                // sort order must be changed because CRITICAL has lowest number
                SortInfo sortInfo = pagingConfig.getSortInfo();
                if (ActiveAlarmBean.SEVERITY.equals(sortInfo.getSortField())) {
                    if (SortDir.ASC == sortInfo.getSortDir()) {
                        sortInfo.setSortDir(SortDir.DESC);
                    }
                    else {
                        sortInfo.setSortDir(SortDir.ASC);
                    }
                }
            }
        }
    }

But the header sorting (ascending or descending) no longer works after I override "load". What I really wanted to do is when user clicks on Ascending it will do descending sorting behavior and while descending it will also do the opposite which is ascending sorting behavior.

user1899646
  • 61
  • 1
  • 3

1 Answers1

0

Sorting should be done on your loader with something like this :

loader.setSortField("id_field");
if (loader.getSortDir().equals(SortDir.DESC)){
   loader.setSortDir(SortDir.ASC);
} else {
   loader.setSortDir(SortDir.DESC);
}
willome
  • 3,062
  • 19
  • 32