SheetXL - v1.0.2
    Preparing search index...

    Interface ISlicer

    A slicer: buttons that filter one column of a table, or one field of pivot tables.

    A slicer holds no selection of its own. On a table, what it shows as selected is the column's filter (ITable.IColumn.getFilter), so a filter set from the column's menu shows on the slicer, and a selection made on the slicer is the column's filter, saved with the table. On pivot tables it is the field's items hidden by hand (IPivotTable.IField.setVisibleItems), the same on every pivot table it filters; a label or value filter on the field does not show on it. Two slicers on one column or field always agree.

    A table slicer follows its table and column through a rename. When the column or its table is deleted, the slicer is deleted with it, in the same step; an undo brings both back. A pivot slicer stays when its pivot tables are deleted, filtering nothing, and is deleted with its field when a pivot table's source no longer has it.

    Where a slicer sits is its movable's (IMovable.getBounds); it moves freely of the cells under it by default.

    const table = sheet.getTables().getByName('Sales');
    const slicer = await table.addSlicer('Region');
    await slicer.selectItems(['East', 'West']);
    interface ISlicer {
        isIModel: true;
        isISlicer: true;
        acceptFlip?(flip: Flip): Flip;
        acceptRotation?(degrees: number): number;
        addListeners(
            listeners: ISlicer.IListeners,
            options?: IListener.Options,
        ): Remove;
        beginCommit(options?: string | ITransaction.OperationOptions): ITransaction;
        clearFilters(options?: ITransaction.OperationOptions): Promise<ISlicer>;
        close(): void;
        delete(options?: ITransaction.OperationOptions): void;
        doBatch<R = any>(
            callback: (commit: ICommit) => R | Promise<R>,
            options?: string | ITransaction.OperationOptions,
        ): R | Promise<R>;
        getCacheName(): string;
        getCaption(): string;
        getColumn(): IColumn | null;
        getColumnCount(): number;
        getConnections?(
            width: number,
            height: number,
            options?: ConnectionsOptions,
        ): readonly Connection[] | null;
        getCrossFilter(): CrossFilter;
        getDefaultAnchorType?(): IAnchored.Type;
        getDescription(): string | null;
        getId(): string;
        getItem(key: string): Promise<ISlicer.Item | null>;
        getItems(): Promise<readonly ISlicer.Item[]>;
        getMovable(): IMovable | null;
        getName?(): string | null;
        getPivotField(): IPivotTable.IField | null;
        getPivotTables(): readonly IPivotTable[];
        getReferences(): ICellRanges | null;
        getRowHeight(): number;
        getSortOrder(): SortOrder;
        getSourceName(): string;
        getStyle(): string;
        getTable(): IPivotTable | ITable | null;
        getType(): string;
        getTypeDescription(): string;
        getVersionId(): number;
        isClosed(): boolean;
        isDefaultLockAspectRatio?(): boolean;
        isDeleted(): boolean;
        isFilterCleared(): boolean;
        isLockedPosition(): boolean;
        isReadOnly(): boolean;
        isShowCaption(): boolean;
        selectItems(
            keys: readonly string[] | null,
            options?: ITransaction.OperationOptions,
        ): Promise<ISlicer>;
        setCaption(
            caption: string | null,
            options?: ITransaction.OperationOptions,
        ): this;
        setColumnCount(
            count: number,
            options?: ITransaction.OperationOptions,
        ): this;
        setCrossFilter(
            crossFilter: CrossFilter,
            options?: ITransaction.OperationOptions,
        ): this;
        setDescription(description: string | null): this;
        setLockedPosition(
            locked: boolean,
            options?: ITransaction.OperationOptions,
        ): this;
        setName?(name: string): this;
        setRowHeight(height: number, options?: ITransaction.OperationOptions): this;
        setShowCaption(
            show: boolean,
            options?: ITransaction.OperationOptions,
        ): this;
        setSortOrder(
            sortOrder: SortOrder,
            options?: ITransaction.OperationOptions,
        ): this;
        setStyle(style: string, options?: ITransaction.OperationOptions): this;
        toJSON(
            toResourceId?: (resource: IResource) => number | null,
        ): ISlicer.JSON | null;
    }

    Hierarchy (View Summary)

    Index
    isIModel: true

    For runtime type checking.

    isISlicer: true

    For runtime type checking.

    • The flip this content takes when asked to mirror as flip states.

      Parameters

      Returns Flip

      Defined by content that can be mirrored, such as a shape or a picture; absent, the content cannot: a frame dragged through its opposite edge is moved there but not mirrored, as Excel does with a chart. Must be pure, as acceptRotation is. A connector may accept each axis on its own.

    • The rotation this content takes when asked to turn by degrees, clockwise.

      Parameters

      • degrees: number

      Returns number

      Defined by content that can be turned, such as a shape or a picture; absent, the content cannot and no rotate handle is offered. Must be pure: it is asked throughout a gesture to draw its preview, and the answer is what the movable stores.

    • Batches all 'transactional' changes until they have all be committed or rolled back.

      Parameters

      • Optionaloptions: string | ITransaction.OperationOptions

        Description of the operation or additional options. Used for tracking undo/redo and history. Default Value User Operation.

      Returns ITransaction

      Any changes that are made to this object will be reflected in the local record but not committed to the transactional store until the batch is popped.

      Useful for operations that are longer running but generally not recommended as it keeps a transaction open. doBatch is the preferred option.

    • Close the record and cleans resources. Can't be undone.

      Returns void

    • Provides a mechanism to perform a set of operations in a batch.

      Type Parameters

      • R = any

      Parameters

      • callback: (commit: ICommit) => R | Promise<R>

        A callback that performs multiple operations all within the same transaction.

      • Optionaloptions: string | ITransaction.OperationOptions

        Description of the operation or additional options. Used for tracking undo/redo and history. Default Value User Operation.

      Returns R | Promise<R>

      Writes are tracked automatically: a batch that performs no state updates (a read-only batch) is elided — the commit id is unchanged, no events fire, and nothing is added to the undo stack or commit log.

    • Returns the name a formula refers to the slicer's selection by: Slicer_Region.

      Returns string

      Made from the column's name when the slicer is created, and kept through a rename of the column, as Excel keeps it.

    • Returns the text shown in the slicer's header.

      Returns string

      getSourceName unless a caption has been set. A slicer added on a pivot field with a caption of its own starts with that caption, and keeps it when the field's changes.

    • Returns the column the slicer filters, or null for a pivot slicer or one naming no column.

      Returns IColumn | null

    • Returns the number of columns the items are laid out in.

      Returns number

    • The points a connector's end may be glued to, in a width by height frame of this content, before the frame is placed.

      Parameters

      Returns readonly Connection[] | null

      Absent, the four edge midpoints — top, left, bottom, right, numbered in that order, each leaving straight out — as Excel offers on a picture, a chart, a slicer or a control. A shape is the exception and answers its geometry's own sites (a triangle's three, a connector's none); a group answers none, since Excel glues to a group's members and never to the group. Must be synchronous: null means the content cannot answer yet and will call options.onReady when it can.

    • Returns how items without data are shown: those whose rows the other columns' filters hide.

      Returns CrossFilter

    • Returns the alternative text used by assistive technologies, or null if none has been set.

      Returns string | null

    • A unique identifier for the record. This will never change.

      Returns string

      This enables the record to be identified across transactions and users in a collaborative environment. The id is store-issued (IStore.create); the store keys all state by it.

    • Returns the item with key, or null.

      Parameters

      • key: string

      Returns Promise<ISlicer.Item | null>

    • Returns the items: the column's distinct values as it shows them, or the field's items, in the slicer's order.

      Returns Promise<readonly ISlicer.Item[]>

      Every row of the column is read, hidden or not. An item has data when at least one row holding it passes the other columns' filters; on pivot tables, when a source row holding it passes the items the first pivot table's other fields hide, and an item the source no longer holds has none. Blanks are one item, keyed '', listed last in ascending order.

    • Returns the movable that places the content on the sheet, or null if it is not placed by one.

      Returns IMovable | null

    • Returns the name, or null if the content has none.

      Returns string | null

      Not defined for content that is never named.

    • Returns the field a pivot slicer filters, as its first pivot table has it; null for a table slicer, or when there is no pivot table.

      Returns IPivotTable.IField | null

      Each pivot table has its own field. Select through the slicer, which changes every one of them.

    • Returns the pivot tables the slicer filters; empty for a table slicer, or once they are deleted.

      Returns readonly IPivotTable[]

    • Returns the cells the content names - a chart's series, a control's linked cell, a slicer's column - or null when it names none.

      Returns ICellRanges | null

      Not where the movable sits: that is IMovable.getRange. The references are formulas the calculation engine holds, so they follow the cells they name through inserts, deletes, cuts, sheet renames and undo, and ContentEvents.onReferencesChange is announced when they have. A reference to deleted cells is left out. Without a running engine the references read as they were set.

    • Returns the height of each item's button, in pixels.

      Returns number

    • Returns the name of what the slicer filters: the column's, or the pivot field's in its source.

      Returns string

      A table slicer's follows a rename of the column.

    • Returns the name of the slicer style.

      Returns string

      'SlicerStyleLight1'

    • Returns an immutable type string.

      Returns string

    • Returns a label for the kind of content, such as Chart or Picture.

      Returns string

    • Every committed update gives the record a new, strictly increasing version id.

      Returns number

      Used with getId to uniquely identify a version of the record.

      The id is an identity, not a per-record count: ids are drawn from a single store-wide sequence bumped once per commit, so all records written in the same commit share an id and a given record's ids increase but are not sequential.

      Records are immutable so a restore/revert doesn't change them — it repoints, and the version id reported is the one for the snapshot the store is currently at. Version ids are never reused: a write after an undo receives an id higher than any previously issued, so a stale reader can always detect the change.

    • Returns true if no more operations are allowed.

      Returns boolean

    • Whether a movable of this content keeps its aspect ratio when resized from a corner, when it states no lock of its own.

      Returns boolean

      Absent, it does not. A picture does.

    • If the model unable to be modified.

      Returns boolean

    • Returns true when every item is selected: the column has no filter, or the field hides no item.

      Returns boolean

    • Returns whether the slicer is marked as not to be moved or resized.

      Returns boolean

    • If the model unable to be modified.

      Returns boolean

    • Returns whether the header is shown.

      Returns boolean

    • Selects the items with keys and no others, by filtering the column or by hiding the field's other items on every pivot table, as one step that can be undone.

      Parameters

      • keys: readonly string[] | null

        The items' keys. null, an empty list or every item clears the filter.

      • Optionaloptions: ITransaction.OperationOptions

      Returns Promise<ISlicer>

      The other columns' filters stay. On a date column the selection is saved as the dates themselves, not their text. A pivot field's label, date and value filters stay.

    • Set the alternative text used by assistive technologies.

      Parameters

      • description: string | null

      Returns this

    • Set the name.

      Parameters

      • name: string

        The name of the content.

      Returns this

    • Parameters

      • OptionaltoResourceId: (resource: IResource) => number | null

      Returns ISlicer.JSON | null

      The current state as JSON, or null once deleted.