Skip to content

Transfer Transfer

Rules

Basic Example

js
const rule = {
    type: "elTransfer",
    field: "transfer",
    title: "Transfer",
    value: [],
    props: {
        data: [
            {label: 'California', key: 'California'},
            {label: 'Illinois', key: 'Illinois'},
            {label: 'Maryland', key: 'Maryland'},
            {label: 'Texas', key: 'Texas'},
            {label: 'Florida', key: 'Florida'},
            {label: 'Colorado', key: 'Colorado'},
            {label: 'Connecticut', key: 'Connecticut'},
        ]
    },
}

Props Configuration Examples

Searchable

js
const rule = {
    type: "elTransfer",
    field: "users",
    title: "User Selection",
    value: [],
    props: {
        data: [
            {label: 'John', key: '1'},
            {label: 'Mary', key: '2'},
            {label: 'Tom', key: '3'},
        ],
        filterable: true,
        filterPlaceholder: "Enter keyword to search",
    },
}

Custom Titles and Buttons

js
const rule = {
    type: "elTransfer",
    field: "permissions",
    title: "Permission Assignment",
    value: [],
    props: {
        data: [
            {label: 'View', key: 'view'},
            {label: 'Edit', key: 'edit'},
            {label: 'Delete', key: 'delete'},
        ],
        titles: ['Available Permissions', 'Selected Permissions'],
        buttonTexts: ['Add', 'Remove'],
    },
}

Custom Data Fields

js
const rule = {
    type: "elTransfer",
    field: "products",
    title: "Product Selection",
    value: [],
    props: {
        data: [
            {name: 'Product A', id: '1'},
            {name: 'Product B', id: '2'},
        ],
        props: {
            key: 'id',
            label: 'name',
        },
    },
}

Events Examples

Listen to Selection Changes

js
const rule = {
    type: "elTransfer",
    field: "users",
    title: "User Selection",
    value: [],
    props: {
        data: [
            {label: 'John', key: '1'},
            {label: 'Mary', key: '2'},
        ],
    },
    on: {
        change: (value, direction, movedKeys) => {
            console.log('Right list changed:', value);
            console.log('Move direction:', direction);
            console.log('Moved keys:', movedKeys);
        },
        'left-check-change': (value, movedKeys) => {
            console.log('Left selection changed:', value, movedKeys);
        },
        'right-check-change': (value, movedKeys) => {
            console.log('Right selection changed:', value, movedKeys);
        },
    },
}

Count Quantity After Selection

js
const rule = [
    {
        type: "elTransfer",
        field: "users",
        title: "User Selection",
        value: [],
        props: {
            data: [
                {label: 'John', key: '1'},
                {label: 'Mary', key: '2'},
                {label: 'Tom', key: '3'},
            ],
        },
        inject: true,
        on: {
            change: ($inject, value) => {
                // Auto-update selected count
                $inject.api.setValue('selectedCount', value.length);
            },
        },
    },
    {
        type: "input-number",
        field: "selectedCount",
        title: "Selected Count",
        props: {
            disabled: true,
        },
    },
]

Full configuration: Element_Transfer

value :Array

Props

Attribute NameDescriptionTypeDefault Value
dataData source for Transferobject[]
filterableWhether searchablebooleanfalse
filterPlaceholderSearch box placeholderstring
filterMethodCustom search methodFunction
targetOrderSorting strategy for right list elements: If original, maintain the same order as data source; If push, newly added elements are placed at the end; If unshift, newly added elements are placed at the beginningenumoriginal
titlesCustom list titlesobject[]
buttonTextsCustom button textobject[]
renderContentCustom data item rendering functionobject
formatChecked state text at top of listobject{}
propsField aliases for data sourceobject
leftDefaultCheckedKey array of checked items in left list in initial stateobject[]
rightDefaultCheckedKey array of checked items in right list in initial stateobject[]
validateEventWhether to trigger form validationbooleantrue

Events

Event NameDescriptionType
changeTriggered when right list elements changeFunction
left-check-changeTriggered when left list elements are selected / deselected by userFunction
right-check-changeTriggered when right list elements are selected / deselected by userFunction

Slots

Slot NameDescription
defaultCustom content for data items, parameter is { option }
left-footerContent at bottom of left list
right-footerContent at bottom of right list
left-emptyContent when left panel is empty or no data matches filter condition
right-emptyContent when right panel is empty or no data matches filter condition

FormCreate is an open-source project released under the MIT License. Free for personal and commercial use.