Transfer

Double column transfer choice box.

Note

  • default value direction: 'right' indicates right column.

Examples

Basic Usage

Simplest of usage.

expand codeexpand code
import { Component } from '@angular/core';
import { SFSchema, SFTransferWidgetSchema } from '@delon/form';
import { NzMessageService } from 'ng-zorro-antd/message';
import { of, delay } from 'rxjs';

@Component({
  selector: 'form-transfer-simple',
  template: ` <sf [schema]="schema" (formSubmit)="submit($event)"></sf> `,
})
export class FormTransferSimpleComponent {
  schema: SFSchema = {
    properties: {
      roles: {
        type: 'number',
        title: '角色',
        enum: [
          { title: 'DNS管理', value: 10 },
          { title: 'ECS管理', value: 11 },
          { title: 'OSS管理', value: 12 },
          { title: 'RDS管理', value: 13 },
        ],
        ui: {
          widget: 'transfer',
          titles: ['未拥有', '已拥有'],
        } as SFTransferWidgetSchema,
        default: [11, 12],
      },
      roles2: {
        type: 'number',
        title: '角色',
        ui: {
          widget: 'transfer',
          titles: ['未拥有', '已拥有'],
          asyncData: () =>
            of([
              { title: 'DNS管理', value: 10 },
              { title: 'ECS管理', value: 11 },
              { title: 'OSS管理', value: 12 },
              { title: 'RDS管理', value: 13 },
            ]).pipe(delay(10)),
        } as SFTransferWidgetSchema,
        default: [11, 12],
      },
    },
  };

  constructor(private msg: NzMessageService) {}

  submit(value: {}): void {
    this.msg.success(JSON.stringify(value));
  }
}

API

schema

PropertyDescriptionTypeDefault
[enum]Data sourceSFSchemaEnumType[]-

ui

PropertyDescriptionTypeDefault
[asyncData]Asynchronous data() => Observable<SFSchemaEnumType[]>-
[titles]Title list, the order is from left to rightstring[]['', '']
[operations]Operation list, the order is from top to buttomstring[]['', '']
[listStyle]A custom CSS style used for rendering the transfer columns. equals to ngStyleobject-
[itemUnit]single unitstringitem
[itemsUnit]multiple unitstringitems
[showSearch]If included, a search box is shown on each columnbooleanfalse
[filterOption]Accept inputValueoption two parameters, return true when option matches, otherwise, return false--
[searchPlaceholder]Placeholder of search boxstring-
[notFoundContent]Text to display when a column is emptystring-
[canMove]Second verification when transfer choice boxfunction-
[change]Callback function when the transfer between columns is complete(options: TransferChange) => void-
[searchChange]Callback function when search field is changed(options: TransferSearchChange) => void-
[selectChange]Callback function when selected items are changed(options: TransferSelectChange) => void-