my.multiLevelSelect
Cascade selection function, mainly used for selecting several levels of associated data, such as province, city and district.
Sample Code
copy
//.json
{
"defaultTitle": "Cascade selector"
}
copy
<!-- .axml -->
<view class="page">
<view class="page-description">Cascade selector API</view>
<view class="page-section">
<view class="page-section-title">my.multiLevelSelect</view>
<view class="page-section-demo">
<button type="primary" onTap="openMultiLevelSelect">Cascade selector</button>
</view>
</view>
</view>
copy
//.js
Page({
openMultiLevelSelect() {
my.multiLevelSelect({
title: 'Cascade selector',//Cascade selector title
list: [
{
name: "City",//entry name
subList: [
{
name: "District A",
subList: [
{
name: "Street A"
},
{
name: "Street B"
}
]
},
{
name: "District B",
subList: [
{
name: "Street C"
},
{
name: "Street D"
}
]
}
]// cascade sub-data list
}],// Cascade data list
success:(res)=>{
my.alert({title:JSON.stringify(res)})
}
});
}
})
Parameters
The incoming parameter is of the Object type with the following attributes:
Property | Type | Required | Description |
title | String | No | Title. |
list | JsonArray | Yes | Selection data list. |
name | String | Yes | Entry name. |
subList | JsonArray | No | Sub-entry list. |
success | Function | No | Callback function upon call success. |
fail | Function | No | Callback function upon call failure. |
complete | Function | No | Callback function upon call completion (to be executed upon either call success or failure). |
Success Callback Function
The incoming parameter is of the Object type with the following attributes:
Property | Type | Description |
success | Boolean | Selection completed or not, returning  false for cancellation. |
result | JsonArray | Selection result, such as [{"name":"City"},{"name":"District A"},{"name":"Street A"}]. |