Package com.extjs.gxt.ui.client.data

Examples of com.extjs.gxt.ui.client.data.SortInfo


   * @param field the field to sort by
   * @param sortDir the sort dir
   */
  public void sort(String field, SortDir sortDir) {
    final StoreEvent<M> event = createStoreEvent();
    event.setSortInfo(new SortInfo(field, sortDir));

    if (!fireEvent(BeforeSort, event)) {
      return;
    }
    SortInfo prev = new SortInfo(sortInfo.getSortField(), sortInfo.getSortDir());

    if (sortDir == null) {
      if (sortInfo.getSortField() != null && !sortInfo.getSortField().equals(field)) {
        sortInfo.setSortDir(SortDir.NONE);
      }
      switch (sortInfo.getSortDir()) {
        case ASC:
          sortDir = SortDir.DESC;
          break;
        case DESC:
        case NONE:
          sortDir = SortDir.ASC;
          break;
      }
    }

    sortInfo.setSortField(field);
    sortInfo.setSortDir(sortDir);

    if (loader != null && loader.isRemoteSort()) {
      Listener<LoadEvent> l = new Listener<LoadEvent>() {
        public void handleEvent(LoadEvent le) {
          loader.removeListener(Loader.Load, this);
          sortInfo = le.<ListLoadConfig> getConfig().getSortInfo();
          event.setSortInfo(sortInfo);
          fireEvent(Sort, event);
        }
      };
      loader.addListener(Loader.Load, l);
      loader.setSortDir(sortDir);
      loader.setSortField(field);
      if (!loader.load()) {
        loader.removeListener(Loader.Load, l);
        sortInfo.setSortField(prev.getSortField());
        sortInfo.setSortDir(prev.getSortDir());
      }
    } else {
      applySort(false);
      fireEvent(DataChanged, event);
    }
View Full Code Here


    }

    if (config.getSortInfo() != null && !Util.isEmptyString(config.getSortInfo().getSortField())) {
      sortInfo = config.getSortInfo();
    } else {
      sortInfo = new SortInfo();
    }

    if (filtersEnabled) {
      filtersEnabled = false;
      applyFilters(filterProperty);
View Full Code Here

   * @param sortDir the sort dir
   */
  @SuppressWarnings("rawtypes")
  public void sort(String field, SortDir sortDir) {
    final StoreEvent<M> event = createStoreEvent();
    event.setSortInfo(new SortInfo(field, sortDir));

    if (!fireEvent(BeforeSort, event)) {
      return;
    }
    SortInfo prev = new SortInfo(sortInfo.getSortField(), sortInfo.getSortDir());
    if (sortDir == null) {
      if (sortInfo.getSortField() != null && !sortInfo.getSortField().equals(field)) {
        sortInfo.setSortDir(SortDir.NONE);
      }
      switch (sortInfo.getSortDir()) {
        case ASC:
          sortDir = SortDir.DESC;
          break;
        case DESC:
        case NONE:
          sortDir = SortDir.ASC;
          break;
      }
    }

    sortInfo.setSortField(field);
    sortInfo.setSortDir(sortDir);

    if (loader != null && loader instanceof RemoteSortTreeLoader) {
      final RemoteSortTreeLoader treeLoader = (RemoteSortTreeLoader) loader;
      if (treeLoader.isRemoteSort()) {
        Listener<LoadEvent> l = new Listener<LoadEvent>() {
          public void handleEvent(LoadEvent le) {
            treeLoader.removeListener(Loader.Load, this);
            sortInfo = le.<ListLoadConfig> getConfig().getSortInfo();
            event.setSortInfo(sortInfo);
            fireEvent(Sort, createStoreEvent());
          }
        };
        treeLoader.addListener(Loader.Load, l);
        treeLoader.setSortDir(sortDir);
        treeLoader.setSortField(field);
        if (!treeLoader.load()) {
          treeLoader.removeListener(Loader.Load, l);
          sortInfo.setSortField(prev.getSortField());
          sortInfo.setSortDir(prev.getSortDir());
        }
        return;
      }
    }

View Full Code Here

      if (obj != null && obj instanceof ListLoadConfig) {
        ListLoadConfig config = le.getConfig();
        if (config.getSortInfo().getSortField() != null) {
          sortInfo = config.getSortInfo();
        } else {
          sortInfo = new SortInfo();
        }
      }
      doInsert(rootWrapper, insert, 0, false, true);
      if (filtersEnabled) {
        filtersEnabled = false;
View Full Code Here

    templateOnColumnWidthUpdated(col, w, tw);
    syncHScroll();
  }

  protected void updateHeaderSortState() {
    SortInfo state = getSortState();
    if (state == null || Util.isEmptyString(state.getSortField())) {
      return;
    }
    if (sortState == null || (!sortState.getSortField().equals(state.getSortField()))
        || sortState.getSortDir() != state.getSortDir()) {
      GridEvent<ModelData> e = new GridEvent<ModelData>(grid);
      e.setSortInfo(state);

      sortState = new SortInfo(state.getSortField(), state.getSortDir());
      int sortColumn = cm.findColumnIndex(state.getSortField());
      if (sortColumn != -1) {
        updateSortIcon(sortColumn, sortState.getSortDir());
      }
      if (grid.isStateful()) {
        Map<String, Object> st = grid.getState();
View Full Code Here

    if (le.config instanceof ListLoadConfig) {
      ListLoadConfig config = (ListLoadConfig) le.config;
      if (config.getSortInfo().getSortField() != null) {
        sortInfo = config.getSortInfo();
      } else {
        sortInfo = new SortInfo();
      }
    }

    if (filtersEnabled) {
      filtersEnabled = false;
View Full Code Here

   *
   * @param field the name of the field to sort by
   * @param dir the sort direction
   */
  public void setDefaultSort(String field, SortDir dir) {
    sortInfo = new SortInfo(field, dir);
  }
View Full Code Here

   *
   * @param field the field to sort by
   * @param sortDir the sort dir
   */
  public void sort(String field, SortDir sortDir) {
    SortInfo prev = new SortInfo(sortInfo.getSortField(), sortInfo.getSortDir());

    sortInfo.setSortField(field);
    sortInfo.setSortDir(sortDir);

    if (loader != null && loader.isRemoteSort()) {
      Listener l = new Listener() {
        public void handleEvent(BaseEvent be) {
          loader.removeListener(Sort, this);
          fireEvent(Sort, createStoreEvent());
        }
      };
      loader.addListener(Loader.Load, l);
      loader.setSortDir(sortDir);
      loader.setSortField(field);
      if (!loader.load()) {
        loader.removeListener(Sort, l);
        sortInfo.setSortField(prev.getSortField());
        sortInfo.setSortDir(prev.getSortDir());
      }
    } else {
      applySort(false);
    }
  }
View Full Code Here

  protected void updateHeaders() {
    innerHd.firstChild().setInnerHtml(renderHeaders());
  }

  protected void updateHeaderSortState() {
    SortInfo state = ds.getSortState();
    if (state == null || state.getSortField() == null) {
      return;
    }
    if (sortState == null || (!sortState.getSortField().equals(state.getSortField()))
        || sortState.getSortDir() != state.getSortDir()) {
      GridEvent e = new GridEvent(grid);
      e.sortInfo = state;
      grid.fireEvent(Events.SortChange, e);
    }
    sortState = new SortInfo(state.getSortField(), state.getSortDir());
    int sortColumn = cm.findColumnIndex(state.getSortField());
    if (sortColumn != -1) {
      updateSortIcon(sortColumn, state.getSortDir());
    }
  }
View Full Code Here

   *
   * @param field the name of the field to sort by
   * @param dir the sort direction
   */
  public void setDefaultSort(String field, SortDir dir) {
    sortInfo = new SortInfo(field, dir);
  }
View Full Code Here

TOP

Related Classes of com.extjs.gxt.ui.client.data.SortInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.