my.multiLevelSelect
Cascade selection function, mainly used for selecting several levels of associated data, such as province, city and district.
Sample Code
copy
// API-DEMO page/API/multi-level-select/multi-level-select.json
{
"defaultTitle": "Cascade selector"
}
copy
<!-- API-DEMO page/API/multi-level-select/multi-level-select.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
// API-DEMO page/API/multi-level-select/multi-level-select.js
Page({
openMultiLevelSelect() {
my.multiLevelSelect({
title: 'Cascade selector',//Cascade selector title
list: [
{
name: "Hangzhou city",//entry name
subList: [
{
name: "Xihu district",
subList: [
{
name: "Gucui street"
},
{
name: "Wenxin street"
}
]
},
{
name: "Shangcheng district",
subList: [
{
name: " Yanan street "
},
{
name: " Longxiangqiao street "
}
]
}
]// 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:
Attributes | Type | Mandatory | 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 for call success |
fail | Function | No | Callback function for call failure |
complete | Function | No | Callback function for call completion (to be executed for both call success and failure) |
Success Callback Function
The incoming parameter is of the Object type with the following attributes:
Attributes | Type | Description |
success | Boolean | Selection completed or not, returning false for cancellation |
result | JsonArray | selection result, such as [{“name”:”Hangzhou city”},{“name”:”Shangcheng district”},{“name”:”Gucui street”}] |