Skip to content

Commit

Permalink
feat(abc:st): add trackBy property (#1760)
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk authored Feb 1, 2024
1 parent 837f4f0 commit f4b2fec
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: jwalton/gh-find-current-pr@v1
- uses: jwalton/gh-find-current-pr@master
id: findPr
with:
state: all
Expand Down
1 change: 1 addition & 0 deletions packages/abc/st/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ When an exception is thrown when parsing column data, *INVALID DATA* will be for
| `[responsive]` | Whether to turn on responsive | `boolean` | `true` ||
| `[responsiveHideHeaderFooter]` | Whether to display the header and footer under the small screen | `boolean` | `false` ||
| `[resizable]` | Resize header of the current table, **Multiple headers not supported** | `STResizable, boolean` | - | - |
| `[trackBy]` | `TrackByFunction` function of list loop `@for` | `TrackByFunction<T>` | - | - |
| `(change)` | Events | `EventEmitter<STChange>` | - | - |
| `(error)` | Error event | `EventEmitter<STError>` | - | - |

Expand Down
1 change: 1 addition & 0 deletions packages/abc/st/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ module: import { STModule } from '@delon/abc/st';
| `[responsive]` | 是否开启响应式 | `boolean` | `true` ||
| `[responsiveHideHeaderFooter]` | 是否在小屏幕下才显示顶部与底部 | `boolean` | `false` ||
| `[resizable]` | 当前表格所有列的调整表头配置项,**不支持多表头** | `STResizable, boolean` | - | - |
| `[trackBy]` | `@for` 列表循环的 `TrackByFunction` 函数 | `TrackByFunction<T>` | - | - |
| `(change)` | 变化时回调,包括:`pi``ps``checkbox``radio``sort``filter``click``dblClick``expand` 变动 | `EventEmitter<STChange>` | - | - |
| `(error)` | 异常时回调 | `EventEmitter<STError>` | - | - |

Expand Down
4 changes: 2 additions & 2 deletions packages/abc/st/st.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
>
@if (showHeader) {
<thead>
@for (row of _headers; track $index) {
@for (row of _headers; track row) {
<tr>
@if ($first && expand) {
<th nzWidth="50px" [rowSpan]="_headers.length"></th>
Expand Down Expand Up @@ -194,7 +194,7 @@
<ng-template [ngTemplateOutlet]="bodyTpl" [ngTemplateOutletContext]="{ $implicit: i, index: index }" />
</ng-template>
} @else {
@for (i of _data; track $index) {
@for (i of _data; track trackBy($index, i)) {
<ng-template [ngTemplateOutlet]="bodyTpl" [ngTemplateOutletContext]="{ $implicit: i, index: $index }" />
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/abc/st/st.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ export class STComponent implements AfterViewInit, OnChanges {
@Input({ transform: numberAttribute }) virtualMinBufferPx = 100;
@Input() customRequest?: (options: STCustomRequestOptions) => Observable<NzSafeAny>;
@Input() virtualForTrackBy: TrackByFunction<STData> = index => index;
@Input() trackBy: TrackByFunction<STData> = (_, item) => item;

/**
* Get the number of the current page
Expand Down

0 comments on commit f4b2fec

Please sign in to comment.