Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update demo #1631

Merged
merged 1 commit into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions packages/abc/st/demo/basic.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,48 @@ Quickly generate tables; use `res` to adapted backend data format.

```ts
import { Component, ViewChild } from '@angular/core';

import { STColumn, STComponent } from '@delon/abc/st';

interface User {
id: number;
picture: {
thumbnail: string;
};
name: {
last: string;
first: string;
};
nat: string;
gender: string;
email: string;
phone: string;
price: number;
registered: Date;
}

@Component({
selector: 'app-demo',
template: `
<button nz-button nzType="primary" (click)="setRow()">setRow Method</button>
<st #st [widthMode]="{ type: 'strict' }" [data]="url" [req]="{ params: params }" [columns]="columns"></st>
`,
`
})
export class DemoComponent {
url = `/users?total=2&field=list`;
params = { a: 1, b: 2 };
@ViewChild('st', { static: false }) private st!: STComponent;
columns: STColumn[] = [
columns: Array<STColumn<User>> = [
{ title: '编号', index: 'id', width: 80 },
{ title: '头像', type: 'img', width: 60, index: 'picture.thumbnail' },
{ title: '头像', index: 'picture.thumbnail', type: 'img', width: 60 },
{ title: '邮箱', index: 'email', width: 80 },
{ title: '电话', index: 'phone' },
{ title: { text: '佣金', optional: '(单位:元)', optionalHelp: '计算公式=订单金额 * 0.6%' }, index: 'price', type: 'currency' },
{ title: '注册时间', type: 'date', index: 'registered' },
{
title: { text: '佣金', optional: '(单位:元)', optionalHelp: '计算公式=订单金额 * 0.6%' },
index: 'price',
type: 'currency'
},
{ title: '注册时间', type: 'date', index: 'registered' }
];

setRow(): void {
Expand Down
2 changes: 1 addition & 1 deletion packages/abc/st/st.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export interface STColumn<T extends STData = any> {
title?: string | STColumnTitle;
/**
* 列数据在数据项中对应的 key,支持 `a.b.c` 的嵌套写法,例如:
* - `id`
* - `id` (需要指定类型才能智能提示)
* - `price.market`
* - `[ 'price', 'market' ]`
*/
Expand Down