# Cascader

<figure><img src="https://125370873-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzdpN2Lz0hzXpnNScDzVt%2Fuploads%2Fgit-blob-176763062552f2ae7304a419743294c044953c41%2Fimage%20(88).png?alt=media" alt=""><figcaption></figcaption></figure>

## Basic

#### JSON Data to show cascading selections

This accepts the content as a JSON packet and all the children nodes are contained in the packet. Each element has the following properties and values corresponding to the property.

|  Property  | Description                                                                                             |
| :--------: | ------------------------------------------------------------------------------------------------------- |
|   `value`  | Recommended keeping this value unique for referring to the node during development                      |
|   `label`  | The label that is displayed to denote each node                                                         |
| `children` | A node may have zero children, or it can have as many nested children as needed to display in a submenu |

```json
[
 {
  "value": "California",
  "label": "California",
  "children": [
   {
    "value": "San Francisco",
    "label": "San Francisco",
    "children": [
     {
      "value": "The Golden Gate Bridge",
      "label": "The Golden Gate Bridge"
     }
    ]
   }
  ]
 },
 {
  "value": "New South Wales",
  "label": "New South Wales",
  "children": [
   {
    "value": "Sydney",
    "label": "Sydney",
    "children": [
     {
      "value": "Sydney Opera House",
      "label": "Sydney Opera House"
     }
    ]
   }
  ]
 }
]
```

#### Default Value

This is the JSON value extracted from cascaded data to show it as the default value when the user focuses on the widget. If the user wants to show the default value from the nested child node, the value should start with the parent node and reach to the children node using the separator as below.

```json
["California","San Francisco","The Golden Gate Bridge"]
```

#### Placeholder

Specifies a hint that describes the expected value. The placeholder shows the hint text in the widget when nothing is selected or entered. This text disappears as soon as a value is entered in the control.

<figure><img src="https://125370873-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzdpN2Lz0hzXpnNScDzVt%2Fuploads%2Fgit-blob-404b38cfa2ddac8b22d6f04d6940b41b271ebf06%2Fimage%20(180).png?alt=media" alt=""><figcaption></figcaption></figure>

## Interaction

#### Event Handlers

| Event                                         | Description                                                                                                                                |
| --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| <mark style="color:blue;">**`Change`**</mark> | <p>This event is activated when the value of the widget is changed. When this event triggers, the associated action gets executed.<br></p> |
| <mark style="color:blue;">**`focus`**</mark>  | This event is triggered when the widget receives focus, meaning it becomes the active element that can accept user input.                  |
| <mark style="color:blue;">**`blur`**</mark>   | This event occurs when the user shifts the focus out of the widget. The corresponding action is executed once the event is triggered.      |

#### Disabled

Disables the user interaction with the element on the page. It visually indicates that the element is inactive and prevents users from interacting with it when applied.

<figure><img src="https://125370873-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzdpN2Lz0hzXpnNScDzVt%2Fuploads%2Fgit-blob-695f356d5e8bc58072102f50922157508eb6122b%2Fimage%20(224).png?alt=media" alt=""><figcaption><p>Read-only</p></figcaption></figure>

#### Hide

This sets whether the widget has to be displayed on the screen when the program is loaded. This shows/hides the widget both on desktop and mobile devices.

<figure><img src="https://125370873-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzdpN2Lz0hzXpnNScDzVt%2Fuploads%2Fgit-blob-4aaa812d0b623487c085a616219a4515138079fb%2Fimage%20(211).png?alt=media" alt="" width="338"><figcaption><p>Set the visibility</p></figcaption></figure>

## Label

Represents the caption for the widget in the user interface. It is recommended to keep the label string short and convey the usage of the widget in the UI.

#### Position

| Property | Description                                                                                                                                                                                                                                                                               |
| :------: | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|  `Left`  | <p>Shows the label on the left side of the tree view<br><br><img src="https://125370873-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzdpN2Lz0hzXpnNScDzVt%2Fuploads%2Fgit-blob-65dc84e7367018bcafd35cf47af352dd3238aa15%2Fimage%20(186).png?alt=media" alt=""></p> |
|   `Top`  | <p>Shows the label on top of the tree view<br><br><img src="https://125370873-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzdpN2Lz0hzXpnNScDzVt%2Fuploads%2Fgit-blob-d41ccdf29dae59b2ccb32a05a408554299d0fa15%2Fimage%20(187).png?alt=media" alt=""><br></p>       |

#### Alignment

| Property | Description                                                                                                                                                                                                                                                                                                     |
| :------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|  `Left`  | <p>Align the text on the left corner of the label area<br><br><img src="https://125370873-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzdpN2Lz0hzXpnNScDzVt%2Fuploads%2Fgit-blob-17a4ca64b45049b65e1fd24dbca640147520bb48%2Fimage%20(194).png?alt=media" alt=""></p>                     |
|  `Right` | <p>Align the text on the right corner of the label area near the tree view<br><br><img src="https://125370873-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzdpN2Lz0hzXpnNScDzVt%2Fuploads%2Fgit-blob-7acedd533c954060bee3bf58bc5f6d45ae18384f%2Fimage%20(195).png?alt=media" alt=""></p> |

#### Width

Enter a number value to set the width of the widget. It can be set in terms of pixels and percentage.

<figure><img src="https://125370873-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzdpN2Lz0hzXpnNScDzVt%2Fuploads%2Fgit-blob-d9be94a993ae1150c38142b56dedb303a7b487eb%2Fimage%20(94).png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://125370873-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzdpN2Lz0hzXpnNScDzVt%2Fuploads%2Fgit-blob-9c4ec770d5e987d374a18dc814e06c349e3f7749%2Fimage%20(95).png?alt=media" alt=""><figcaption></figcaption></figure>

## Layout

#### Widget Tooltip

This tooltip pops up when the user moves the mouse over the input area of the widget. It is commonly used to hint at the type of input the user needs to provide.

The tooltip will be immediately shown when the user's mouse hovers over the widget, and immediately hides when the user's mouse leaves. This information will be contextual, useful, and informative.

<figure><img src="https://125370873-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzdpN2Lz0hzXpnNScDzVt%2Fuploads%2Fgit-blob-01429cb50c3ec8aa7c9fc89292a780b5747ebbd9%2Fimage%20(96).png?alt=media" alt=""><figcaption></figcaption></figure>

## Advanced

#### Show Clear Button

Displays an 'x' symbol at the right end of the widget box, and the selected value is cleared out when the user clicks the clear button.

<figure><img src="https://125370873-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzdpN2Lz0hzXpnNScDzVt%2Fuploads%2Fgit-blob-fa660f1cba3461d086f7db6578ee8e57637ecb4c%2Fimage%20(97).png?alt=media" alt=""><figcaption></figcaption></figure>

#### Searchable

Provides users with the ability to search using a keyword and show the filtered-down results for better usability. Users can start typing in the input box and the filtered results will be shown as they type.

<figure><img src="https://125370873-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzdpN2Lz0hzXpnNScDzVt%2Fuploads%2Fgit-blob-17937512d0786355405219d1ba81f39407510d4c%2Fimage%20(98).png?alt=media" alt=""><figcaption></figcaption></figure>

## Style

<table><thead><tr><th width="218" align="center">Property</th><th>Description</th></tr></thead><tbody><tr><td align="center">Label</td><td>Set the colour of the label text. Recommended to set in contrast with the background.</td></tr><tr><td align="center">Background</td><td>Users can change the colour of the text background using this property. It has all the RGB colour ranges to pick from. It is recommended to use a corresponding background colour that shows the font clearly.</td></tr><tr><td align="center">Border Color</td><td>Set the colour to the border lines. The border lines will be shown only if that is enabled.</td></tr><tr><td align="center">Border Radius</td><td>This sets the radius of the widget's corners, enabling rounded corners on the widget. This value is defined in "px" terms.</td></tr><tr><td align="center">Text</td><td>Set the colour of the text used to show the tree view content. Recommended to set in contrast with the background.</td></tr><tr><td align="center">Accent</td><td><p>An <strong>accent</strong> is a typically bright colour that contrasts with the more utilitarian background and foreground colours within a colour scheme. These are present in the visual style of many platforms (though not all).</p><p>On the web, an accent is sometimes used in input elements for the active portion of the control, for instance, the background of a checked checkbox. <a href="https://developer.mozilla.org/en-US/docs/Glossary/Accent">MSDN web docs</a></p></td></tr><tr><td align="center">Margin</td><td>This value is set in terms of "px" number which creates the space between the border and the content of the widget.</td></tr><tr><td align="center">Padding</td><td>This value is set in terms of "px" number which creates the space between the border and outer elements.</td></tr><tr><td align="center">Border Width</td><td>Set the thickness of the border of the widget using this value. It is defined using "px" terms.</td></tr></tbody></table>
