How to use the @bentley/ui-core.SortDirection.NoSort function in @bentley/ui-core

To help you get started, we’ve selected a few @bentley/ui-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imodeljs / imodeljs / ui / components / src / ui-components / table / SimpleTableDataProvider.ts View on Github external
public async sort(columnIndex: number, sortDirection: SortDirection): Promise {
    // istanbul ignore next
    if (columnIndex < 0 || columnIndex >= this._columns.length)
      return;

    this._sortColumnIndex = columnIndex;
    this._sortDirection = sortDirection;

    if (sortDirection === SortDirection.NoSort) {
      if (this._filterDescriptors)
        await this.applyFilterDescriptors(this._filterDescriptors);
      else
        this.resetRowIndices();
      return;
    }

    this._secondarySortColumnStack = [];
    this._secondarySortColumnStack.push(columnIndex);

    // Sort by the column
    const dataProvider = this;
    this._rowItemIndices.sort((a: number, b: number) => {
      return dataProvider.sortDispatcher(dataProvider._items[a], dataProvider._items[b], columnIndex, sortDirection);
    });
github imodeljs / imodeljs / ui / components / src / ui-components / table / component / Table.tsx View on Github external
private _handleGridSort = (columnKey: string, sortDirection: "ASC" | "DESC" | "NONE") => {
    let directionEnum: SortDirection;

    switch (sortDirection) {
      case "ASC":
        directionEnum = SortDirection.Ascending;
        break;
      case "DESC":
        directionEnum = SortDirection.Descending;
        break;
      case "NONE":
      default:
        directionEnum = SortDirection.NoSort;
        break;
    }

    // Sort the column
    this.gridSortAsync(columnKey, directionEnum); // tslint:disable-line:no-floating-promises
  }
github imodeljs / imodeljs / presentation / components / src / table / DataProvider.ts View on Github external
protected invalidateCache(props: CacheInvalidationProps): void {
    super.invalidateCache(props);

    if (props.descriptor) {
      this._filterExpression = undefined;
      this._sortColumnKey = undefined;
      this._sortDirection = UiSortDirection.NoSort;
    }

    if (props.descriptor || props.descriptorConfiguration) {
      if (this.getColumns)
        this.getColumns.cache.clear!();
      if (this.onColumnsChanged)
        this.onColumnsChanged.raiseEvent();
    }

    if (props.size || props.content) {
      if (this._pages)
        this._pages.invalidatePages();
      if (this.onRowsChanged)
        this.onRowsChanged.raiseEvent();
    }
  }
github imodeljs / imodeljs / presentation / components / src / table / DataProvider.ts View on Github external
pageSize?: number;

  /** Number of pages cached in the data provider. Defaults to [[TABLE_DATA_PROVIDER_DEFAULT_CACHED_PAGES_COUNT]] */
  cachedPagesCount?: number;

  /** Display type to use when requesting data from the backend. Defaults to [[DefaultContentDisplayTypes.GRID]] */
  displayType?: string;
}

/**
 * Presentation Rules-driven table data provider.
 * @public
 */
export class PresentationTableDataProvider extends ContentDataProvider implements IPresentationTableDataProvider {
  private _sortColumnKey: string | undefined;
  private _sortDirection = UiSortDirection.NoSort;
  private _filterExpression: string | undefined;
  private _pages: PageContainer>;
  public onColumnsChanged = new TableDataChangeEvent();
  public onRowsChanged = new TableDataChangeEvent();

  /** Constructor. */
  constructor(props: PresentationTableDataProviderProps) {
    super(props.imodel, props.ruleset, props.displayType || DefaultContentDisplayTypes.Grid);
    this._pages = new PageContainer(props.pageSize || TABLE_DATA_PROVIDER_DEFAULT_PAGE_SIZE,
      props.cachedPagesCount || TABLE_DATA_PROVIDER_DEFAULT_CACHED_PAGES_COUNT);
    this.pagingSize = props.pageSize || TABLE_DATA_PROVIDER_DEFAULT_PAGE_SIZE;
  }

  /** Get key of ECInstance that's represented by the supplied row */
  public getRowKey(row: RowItem): InstanceKey {
    return InstanceKey.fromJSON(JSON.parse(row.key));
github imodeljs / imodeljs / ui / components / src / ui-components / table / SimpleTableDataProvider.ts View on Github external
public async applyFilterDescriptors(filterDescriptors: CompositeFilterDescriptorCollection): Promise {
    this._filterDescriptors = filterDescriptors;

    this._rowItemIndices.splice(0);

    this._items.forEach((row: RowItem, i: number) => {
      if (filterDescriptors.evaluateRow(row))
        this._rowItemIndices.push(i);
    });

    if (this._sortDirection !== SortDirection.NoSort) {
      await this.sort(this._sortColumnIndex, this._sortDirection);
    }
  }