All Products
Search
Document Center

Multilevel select

Last Updated: Feb 19, 2021

my.multiLevelSelect(Object)

Note: This interface is only supported in mPaaS 10.1.32 and later versions.

Cascaded selection is mainly used for selecting several levels of associated data, such as province, city and district.

Input parameters

Parameter Type Required Description
title String No Title
list JsonArray Yes Selection data 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).

list objects

Parameter Type Required Description
name String Yes Entry name
subList JsonArray No Sub-entry list.

Output parameters

Parameter Type Description
success Boolean Selection completed or not, returning false for cancellation.
result JsonArray Selection result, for example, [{“name”:”Hangzhou”},{“name”:”Xihu District”},{“name”:”Gucui Subdistrict”}].

Code sample

  1. // API-DEMO page/API/multi-level-select/multi-level-select.json
  2. {
  3. "defaultTitle": "cascaded selector"
  4. }
  1. <!-- API-DEMO page/API/multi-level-select/multi-level-select.axml-->
  2. <view class="page">
  3. <view class="page-description">cascaded selector API</view>
  4. <view class="page-section">
  5. <view class="page-section-title">my.multiLevelSelect</view>
  6. <view class="page-section-demo">
  7. <button type="primary" onTap="openMultiLevelSelect">cascaded selector</button>
  8. </view>
  9. </view>
  10. </view>
  1. // API-DEMO page/API/multi-level-select/multi-level-select.js
  2. Page({
  3. openMultiLevelSelect() {
  4. my.multiLevelSelect({
  5. title: 'cascaded selector',//Title for cascaded selection
  6. list: [
  7. {
  8. name: "Hangzhou",//Entry name
  9. subList: [
  10. {
  11. name: "Xihu District",
  12. subList: [
  13. {
  14. name: "Gucui Subdistrict"
  15. },
  16. {
  17. name: "Wenxin Subdistrict "
  18. }
  19. ]
  20. },
  21. {
  22. name: "Shangcheng District",
  23. subList: [
  24. {
  25. name: "Yan'an Subdistrict"
  26. },
  27. {
  28. name: "Longxiangqiao Subdistrict"
  29. }
  30. ]
  31. }
  32. ]//sub-level data list
  33. }],//data list
  34. success:(res)=>{
  35. my.alert({title:JSON.stringify(res)})
  36. }
  37. });
  38. }
  39. })