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:

AttributesTypeMandatoryDescription
titleStringNoTitle
listJsonArrayYesselection data list
nameStringYesEntry name
subListJsonArrayNoSub-entry list
successFunctionNoCallback function for call success
failFunctionNoCallback function for call failure
completeFunctionNoCallback 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:

AttributesTypeDescription
successBooleanSelection completed or not, returning  false for cancellation
resultJsonArrayselection result, such as [{“name”:”Hangzhou city”},{“name”:”Shangcheng district”},{“name”:”Gucui street”}]