BusinessTreeSelect
Provides the same functionality as BusinessSelect, but works with tree data instead of flat lists.
Define once, use conveniently across your entire application.
Here's the component initialization example:
import { BusinessTreeSelectBuilder } from 'react-admin-kit';
// Define type for code hinting
type TreeSelectType = 'org';
const BusinessTreeSelect = BusinessTreeSelectBuilder<TreeSelectType>(
{
apis: [
{
type: 'org',
api: queryOrgFunction,
},
],
})
// Usage in pages
<BusinessTreeSelect type="org" />;
Since it processes tree data, pagination is not needed. The API should return an array of objects directly, with
nameas display text andidas value by default.
Basic Usage
BusinessTreeSelect is a wrapper around Antd TreeSelect, so it accepts all Antd TreeSelect properties.
Cascading
-
This example shows department options cascading based on company selection.
-
Use
queryParamsto pass parameters to the API.
Clear Cache
Use clearTreeSelectCache(type: string) to clear cache. Omitting type clears all type caches.
onLoad Event
Triggered when dropdown data finishes loading. This event is useful for certain scenarios, such as auto-selecting the first item.
API
BusinessTreeSelectBuilder
| Property | Description | Type | Default |
|---|---|---|---|
| apis | define the business tree select | ApiType[] | [] |
| defaultProps | default props | {} |
ApiType
| Property | Description | Type | Default |
|---|---|---|---|
| api | api request for options data | (params: { [key: string]: any; }) => Promise<any> | '-' |
| type | business tree select type | string | '-' |
| defaultProps | default props (higher priority than Builder-level settings) | '-' |
BusinessTreeSelect
BusinessTreeSelect type is a combination of BusinessTreeSelectSelfType and TreeSelectProps.
BusinessTreeSelectSelfType
| Property | Description | Type | Default |
|---|---|---|---|
| type | business tree select type | string | Required |
| nodeDisabled | disable option. | ((node: any) => boolean) | -- |
| queryParams | pass params to api request. see demo. | Record<string, any> | -- |
| noCache | disable cache (higher priority) | boolean | false |
| onLoad | callback after options data finish request | ((options: any) => void) | - |