如何防止对点击标题单元格进行排序?

时间:2019-09-05 11:04:17

标签: angular angular-material

我在物料表中实现列大小调整。我的问题是要对列进行排序。

const upFn = () => {
    document.removeEventListener('mousemove', moveFn);
    document.removeEventListener('mouseup', upFn);
    this.inMove = false;
    // How to prevent sorting here ?
};

1 个答案:

答案 0 :(得分:0)

尝试一下:

<mat-header-cell
                    #headercell
                    (mousemove)="mousemove($event, i)"
                    (mousedown)="resizeTable($event, i)"
                    fxLayout="row"
                    fxLayoutAlign="space-between stretch"
                    [fxFlex]="column.width"
                    *matHeaderCellDef
                    [disabled]="isResizeActive"
                >
    <div fxFlex [disabled]="column.isSortable === false || isResizeActive" mat-sort-header>
                        {{ column.title || column.field }}
                    </div>
</mat-header-cell>

在您的方法中,只需将标志设置为true

const upFn = () => {
    document.removeEventListener('mousemove', moveFn);
    document.removeEventListener('mouseup', upFn);
    this.inMove = false;
    this.isResizeActive = true;
};