UI APIs

multiLevelSelect

Cascade selection picker for hierarchical data like provinces, cities, and districts.

Overview

my.multiLevelSelect provides a cascade selection function, mainly used for selecting several levels of associated data, such as province, city, and district. Users can drill down through hierarchical options to make their selection.

Sample Code

function openMultiLevelSelect() {
  my.multiLevelSelect({
    title: 'Cascade selector',
    list: [
      {
        name: "City",
        subList: [
          {
            name: "District A",
            subList: [
              {
                name: "Street A"
              },
              {
                name: "Street B"
              }
            ]
          },
          {
            name: "District B",
            subList: [
              {
                name: "Street C"
              },
              {
                name: "Street D"
              }
            ]
          }
        ]
      }
    ],
    success: (res) => {
      my.alert({
        title: JSON.stringify(res)
      });
    }
  });
}

Parameters

The incoming parameter is of the Object type with the following attributes:

PropertyTypeRequiredDescription
titleStringNoTitle.
listJsonArrayYesSelection data list.
nameStringYesEntry name.
subListJsonArrayNoSub-entry list.
successFunctionNoCallback function upon call success.
failFunctionNoCallback function upon call failure.
completeFunctionNoCallback 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:

PropertyTypeDescription
successBooleanSelection completed or not, returning false for cancellation.
resultJsonArraySelection result, such as [{"name":"City"},{"name":"District A"},{"name":"Street A"}].

Usage Notes

  • The list parameter defines the hierarchical structure of selectable items
  • Each item can have a subList array containing child items
  • Users can navigate through multiple levels before making a final selection
  • Canceling the selection returns success: false in the callback