Jump to content

Help:DropDown

From RiskiPedia
Revision as of 13:12, 5 September 2025 by Gavinandresen (talk | contribs)

Help:DropDown

The `<dropdown>` tag creates an interactive dropdown menu that displays data from a DataTable2 table, allowing you to select a row.

Syntax

The `<dropdown>` tag supports these attributes:

  • `table`: (Required) The name of the DataTable2 table to display.
  • `title`: (Optional) The label shown when no item is selected. Defaults to "Select".
  • `label_column`: (Optional) The table column to use as the display label. Defaults to the first column.
  • `default`: (Optional) Which item is selected by default (e.g. default=Apple)
  • `default-index`: (Optional) The zero-based index of the default selected item (takes precedence over `default`).

Basic syntax:

<dropdown table="TableName" title="Choose an option" label_column="ColumnName" default="DefaultLabel" default-index="0" />

Usage

1. Use the `<dropdown>` tag in your wikitext, specifying the `table` attribute with the name of a DataTable2 table. 2. Optionally, customize the dropdown with `title`, `label_column`, `default`, or `default-index`.

The dropdown shows values from the specified column (or the first column by default). Selecting an item makes the row's data available to Help:RiskDisplay RiskDisplay elements on the page.

Examples

Basic Dropdown

Display a dropdown using the "Fruits" table, showing the "Name" column:

<dropdown table="Fruits" title="Select a fruit" label_column="Name" />

This lists values like "Apple", "Banana", and "Orange" if they exist in the "Name" column.

Dropdown with Default Selection

Set "Banana" as the default selected item:

<dropdown table="Fruits" title="Select a fruit" label_column="Name" default="Banana" />

Dropdown with Default Index

Select the second item (index 1) by default:

<dropdown table="Fruits" title="Select a fruit" label_column="Name" default-index="1" />

Fully-Qualified Table Name

For a table on a subpage (e.g., "Data:Fruits" under "Market"):

<dropdown table="Market/Data:Fruits" title="Select a fruit" label_column="Name" />

Notes

  • The `table` attribute can be a simple name (e.g., "Fruits"), a page-specific name (e.g., "Market:Fruits"), or a subpage (e.g., "Market/Data:Fruits"). The system searches the current page and its "Data/" subpage if needed.
  • If the table is empty or not found, an error message will appear (e.g., "dropdown: empty DataTable2 table Fruits").
  • Ensure `label_column` matches a column in the table, or an error will list valid columns.
  • The dropdown's width adjusts automatically based on the longest label or title.

Troubleshooting

  • **Error: "dropdown: missing table attribute"** – Ensure the `table` attribute is included.
  • **Error: "dropdown: cannot find DataTable2 table"** – Verify the table exists and the name is correct (check for typos or incorrect page/subpage paths).
  • **Error: "dropdown: no column named X"** – Confirm `label_column` matches a column in the table.
  • **Dropdown appears empty** – Check that the DataTable2 table contains data and is properly formatted.