All Products
Search
Document Center

Cascade picker

Last Updated: May 27, 2021

AUCascadePicker provides a multi-level cascade selector that supports selection at a maximum of three levels.

Sample image

API description

 
  1. /**
  2. * Set the selected list.
  3. */
  4. public void setDateData(List<PickerDataModel> strList)
  5. /**
  6. * Start the selected items.
  7. * @param model
  8. */
  9. public void setSelectedItem(PickerDataModel model)
  10. /**
  11. *Set listeners for the selected items.
  12. * @param model
  13. */
  14. public void setOnLinkagePickerListener(OnLinkagePickerListener listener)

JSAPI description

API

antUIGetCascadePicker

API usage

 
  1. AlipayJSBridge.call('antUIGetCascadePicker',
  2. {
  3. title: 'nihao',// The cascade option title.
  4. selectedList:[{"name":"Hangzhou",subList:[{"name":"Shangcheng District"}]}],
  5. list: [
  6. {
  7. name: "Hangzhou",// The entry name.
  8. subList: [
  9. {
  10. name: "Xihu District",
  11. subList: [
  12. {
  13. name: "Gucui Street"
  14. },
  15. {
  16. name: "Wenxin Street"
  17. }
  18. ]
  19. },
  20. {
  21. name: "Shangcheng District",
  22. subList: [
  23. {
  24. name: "Yan'an Street"
  25. },
  26. {
  27. name: "Longxiangqiao Street"
  28. }
  29. ]
  30. }
  31. ]// The cascade sub-data list.
  32. }
  33. ]// The cascade data list.
  34. },
  35. function(result){
  36. console.log(result);
  37. });

Input parameters

Name Type Description Required Default value Version
title String The cascade control title. No 10.1.2
selectedList JSON Selected state, specifying the selected sub-item and in a format the same as that of the input parameter ([{“name”:”Hangzhou City”,subList:[{“name”:”Shangcheng District”}]}]) No 10.1.2
List JSON The selector data list. Yes 10.1.2
name (a name in a list) String The entry name. Yes 10.1.2
subList (a sublist in a list) JSON The sub-entry list. No 10.1.2
fn function The callback function after selection is complete. No 10.1.2

Output parameters

Name Type Description Version
success bool Whether selection is complete. If selection is canceled, false is returned. 10.1.2
result JSON The selection result, for example, [{"name":"Hangzhou City",subList:[{"name":"Shangcheng District"}]}]. 10.1.2

Sample code

 
  1. AUCascadePicker datePicker = new AUCascadePicker(PickerActivity.this);
  2. datePicker.setDateData(datas);
  3. datePicker.setOnLinkagePickerListener(new AUCascadePicker.OnLinkagePickerListener() {
  4. @Override
  5. public void onLinkagePicked(PickerDataModel msg) {
  6. PickerDataModel model = msg;
  7. AuiLogger.info("onLinkagePicked", "onLinkagePicked:"+msg.name+ model);
  8. StringBuilder sb = new StringBuilder();
  9. while (msg != null){
  10. sb.append(msg.name+" ");
  11. if(msg.subList != null && msg.subList.size() > 0) {
  12. msg = msg.subList.get(0);
  13. }else {
  14. msg = null;
  15. }
  16. }
  17. box3.getInputEdit().setText(sb);
  18. }
  19. });
  20. datePicker.show();