ngx-datatable: 如何固定摘要行(在滚动时)?

ngx-datatable: how to make summary row fixed (on scrolling)?

我做了一个固定的header

<ngx-datatable
[scrollbarV]="true">

但是当我滚动页面时如何修复摘要行呢?

 <p-dialog 
  ...
  <ngx-datatable
    ...
    [scrollbarV]="true"
    >

<ngx-datatable-column name="AMOUNT" [summaryTemplate]="totalCost" [flexGrow]="1">
  ...
</ngx-datatable-column>

...

  <ng-template #totalCost>
   ...
  </ng-template>


</p-dialog>

开始 - 这是 example with fixed multiline footer including a summary, here's the link to the source

同样也可以应用于 header,因此您的自定义 header-component.ts 可能如下所示:

import { Component } from '@angular/core';

@Component({
  selector: 'header-demo',
  template: `
  <ngx-datatable
    class="material"
    [rows]="rows"
    [columns]="columns"
    [columnMode]="'force'"
    [footerHeight]="50"
    [headerHeight]="100"
    [rowHeight]="'auto'"
    [scrollbarV]="true">
    <ngx-datatable-header>
      <ng-template 
        ngx-datatable-header-template 
        let-rowCount="rowCount"
        let-pageSize="pageSize"
        let-selectedCount="selectedCount"
        let-curPage="curPage"
        let-offset="offset">
        <div style="padding: 5px 10px">
          <div>
            <strong>Summary</strong>: Amount
          </div>
          <hr style="width:100%" />
          <div>
            Rows: {{rowCount}} |
            Size: {{pageSize}} |
            Current: {{curPage}} |
            Offset: {{offset}}
          </div>
        </div>
      </ng-template>
    </ngx-datatable-header>
  </ngx-datatable>
`
})
export class HeaderDemoComponent {
  rows = [];

  columns = [
    ...
    ..
    .
  ];

  ...
  ..
  .

}

如您所见,在您想要实现的 div-construction 中形成任何内容都是完全合法的..

Hint: Make use of the header and cell class declarations

像这个例子一样实现你想要的样式:

 <ngx-datatable-column 
     name="SomeColumn" 
     [headerClass]="'ngxSomeColumnNameHeader'" 
     [cellClass]="'ngxSomeColumnNameCell'"
     prop="SomeColumnName">
     ...
     ..
 </ngx-datatable-column> 

并考虑在 ngx-datatable 标签中使用 [columnMode]="'force'", [rowHeight]="'auto'" & [limit]="12" 如果需要..