# Class: TableSection

## LuCI .form. TableSection

The `TableSection` class maps all or - if `filter()` is overridden - a subset of the underlying UCI configuration sections of a given type.

Layout wise, the configuration section instances mapped by the section element (sometimes referred to as "section nodes") are rendered as rows within an HTML table element, with an optional section remove button in the last column and a section add button below the table, depending on the value of the `addremove` property.

#### new LuCI.form.TableSection(form, section_type, title, description)

form.js, line 2418

  Name | Type | Description
  --- | --- | ---
  `form` | LuCI.form.Map | LuCI.form.JSONMap | The configuration form to which this section is added. It is automatically passed by `section()`.
  `section_type` | string | The type of the UCI section to map.
  `title` | string | optional The title caption of the form section element.
  `description` | string | optional The description text of the form section element.

### Extends

- LuCI.form.TypedSection

### Members

#### actionstitlestring function

  Set a custom text for the actions column header row when actions buttons are present.

  Default Value:
    - null

#### exteditstring function

  Enables a per-section instance row `Edit` button which triggers a certain action when clicked. Set to a string, the string value is used as a `String.format()` pattern with the name of the underlying UCI section as the first format argument. The result is then interpreted as a URL which LuCI will navigate to when the user clicks the edit button.

  If set to a function, this function will be registered as a click event handler on the rendered edit button, receiving the section instance name as the first and the DOM click event as the second argument.

  Default Value:
    - null

#### filterrowboolean

  Optional table filtering for table sections.

  Set `filterrow` to `true` to display a filter header row in the generated table with per-column text fields to search for string matches in the column. The filter row appears after the titles row.

  The filters work cumulatively: text in each field shall match an entry for the row to be displayed. The results are filtered live. Matching is case-sensitive, and partial, i.e. part or all of the result includes the search string.

  The filter fields assume the placeholder text `Filter` suffixed with the column name, to ease correlation of filter fields to their corresponding column entries on narrow displays which might fold the columns over multiple lines.

  Default Value:
    - null

#### footerArray.<string> function

  Optional footer row for table sections.

  Set `footer` to one of:

  - a function that returns a table row (`tr`) or node `E('...')`
  - an array of string cell contents (first entry maps to the name column if present).

  This is useful for providing sum totals, extra function buttons or extra space.

  The default implementation returns an empty node.

  Default Value:
    - E([])

#### max_colsnumber

  Specify a maximum amount of columns to display. By default, one table column is rendered for each child option of the form section element. When this option is set to a positive number, then no more columns than the given amount are rendered. When the number of child options exceeds the specified amount, a `More…` button is rendered in the last column, opening a modal dialog presenting all options elements in `NamedSection` style when clicked.

  Default Value:
    - null

#### modaltitlestring function

  Override the per-section instance modal popup title caption shown when clicking the `More…` button in a section specifying `max_cols`. Set to a string, it will be used as a `String.format()` pattern with the name of the underlying UCI section as the first argument. Set to a function, the function will be invoked with the section name as the first argument, and its return value is used as a caption after converting it to a string. If this property is not set, the default is the name of the underlying UCI configuration section.

  Default Value:
    - null

#### nodescriptionsboolean

  Set to `true`, the header row with the descriptions of options will not be displayed. By default, the row of descriptions is automatically displayed when at least one option has a description.

  Default Value:
    - false

#### rowcolorsboolean

  Set to `true`, alternating `cbi-rowstyle-1` and `cbi-rowstyle-2` CSS classes are added to the table row elements. Not all LuCI themes implement these row style classes. The default is `false`.

  Default Value:
    - false

#### sectiontitlestring function

  Override the per-section instance title caption shown in the first column of the table unless `anonymous` is set to true. Set to a string, it will be used as a `String.format()` pattern with the name of the underlying UCI section as the first argument. Set to a function, the function will be invoked with the section name as the first argument and its return value used as a caption, after converting it to a string. If this property is not set, the default is the name of the underlying UCI configuration section.

  Default Value:
    - null

#### sortableboolean

  Set to `true`, a sort button is added to the last column, allowing the user to reorder the section instances mapped by the section form element.

  Default Value:
    - false

#### addbtntitlestring function

  Override the caption used for the section add button at the bottom of the section form element. Set to a string, it will be used as-is. Set to a function, the function will be invoked and its return value is used as a caption, after converting it to a string. If this property is not set, the default is `Add`.

  Default Value:
    - null

#### addremoveboolean

  If set to `true`, the user may add or remove instances from the form section widget, otherwise only pre-existing sections may be edited. The default is `false`.

  Default Value:
    - false

#### anonymousboolean

  If set to `true`, mapped section instances are treated as anonymous UCI sections, which means that section instance elements will be rendered without a title element and that no name is required when adding new sections. The default is `false`.

  Default Value:
    - false

#### cloneableboolean

  Set to `true`, a clone button is added to the button column, allowing the user to clone section instances mapped by the section form element. The default is `false`.

  Default Value:
    - false

#### clonebtntitlestring function

  Override the caption used for the section clone button at the bottom of the section form element. Set to a string, it will be used as-is. Set to a function, the function will be invoked and its return value is used as a caption, after converting it to a string. If this property is not set, the default is `Clone`.

  Default Value:
    - null

#### delbtntitlestring function

  Override the caption used for the section delete button at the bottom of the section form element. Set to a string, it will be used as-is. Set to a function, the function will be invoked and its return value is used as a caption, after converting it to a string. If this property is not set, the default is `Delete`.

  Default Value:
    - null

#### hidetitleboolean

  If set to true, the title caption of the form section element which is normally rendered before the start of the section content will not be rendered in the UI. The default is false, meaning that the title is rendered.

  Default Value:
    - false

#### readonlyparentoptionLuCI.form.AbstractValue

  Access the parent option container instance.

  In case this section is nested within an option element container, this property will hold a reference to the parent option instance.

  If this section is not nested, the property is `null`.

#### tabbedboolean

  When set to `true`, instead of rendering section instances one below another, treat each instance as a separate tab pane and render a tab menu at the top of the form section element, allowing the user to switch among instances. The default is `false`.

  Default Value:
    - false

#### uciconfigstring

  Override the UCI configuration name to read the section IDs from. By default, the configuration name is inherited from the parent `Map`. By setting this property, a deviating configuration may be specified. The default of `null` means inherit from the parent form.

  Default Value:
    - null

### Methods

#### abstractaddModalOptions(modalSection, section_id, ev){*|Promise.<*>}

form.js, line 3512

  Add further options to the per-section instanced modal popup.

  This function may be overridden by user code to perform additional setup steps before displaying the more options modal which is useful to e.g. query additional data or to inject further option elements.

  The default implementation of this function does nothing.

  Name | Type | Description
  --- | --- | ---
  `modalSection` | LuCI.form.NamedSection | The `NamedSection` instance about to be rendered in the modal popup.
  `section_id` | string | The ID of the underlying UCI section the modal popup belongs to.
  `ev` | Event | The DOM event emitted by clicking the `More…` button.

  ##### Returns:

  Type | Description
  --- | ---
  * | Promise.<*> | Return values of this function are ignored but if a promise is returned, it is run to completion before the rendering is continued, allowing custom logic to perform asynchronous work before the modal dialog is shown.

#### inherited append(obj)

form.js, line 219

  Add another form element as children to this element.

  Name | Type | Description
  --- | --- | ---
  `obj` | AbstractElement | The form element to add.

#### inherited cfgvalue(section_id, option){null|string|Array.<string>|Object.<string, (null|string|Array.<string>)>}

form.js, line 1098

  Query underlying option configuration values.

  This function is sensitive to the amount of arguments passed to it; if only one argument is specified, the configuration values of all options within this section are returned as a dictionary.

  If both the section ID and an option name are supplied, this function returns the configuration value of the specified option only.

  Name | Type | Description
  --- | --- | ---
  `section_id` | string | The configuration section ID
  `option` | string | optional The name of the option to query

  ##### Returns:

  Type | Description
  --- | ---
  null | string | Array.<string> | Object.<string, (null|string|Array.<string>)> | Returns either a dictionary of option names and their corresponding configuration values or just a single configuration value, depending on the amount of passed arguments.

#### inherited abstractfilter(section_id){boolean}

form.js, line 901

  Filter UCI section IDs to render.

  The filter function is invoked for each UCI section ID of a given type and controls whether the given UCI section is rendered or ignored by the form section element.

  The default implementation always returns `true`. User code or classes extending `AbstractSection` may override this function with custom implementations.

  Name | Type | Description
  --- | --- | ---
  `section_id` | string | The UCI section ID to test.

  ##### Returns:

  Type | Description
  --- | ---
  boolean | Returns `true` when the given UCI section ID should be handled and `false` when it should be ignored.

#### inherited formvalue(section_id, option){null|string|Array.<string>|Object.<string, (null|string|Array.<string>)>}

form.js, line 1131

  Query the underlying option widget input values.

  This function is sensitive to the amount of arguments passed to it; if only one argument is specified, the widget input values of all options within this section are returned as a dictionary.

  If both the section ID and an option name are supplied, this function returns the widget input value of the specified option only.

  Name | Type | Description
  --- | --- | ---
  `section_id` | string | The configuration section ID
  `option` | string | optional The name of the option to query

  ##### Returns:

  Type | Description
  --- | ---
  null | string | Array.<string> | Object.<string, (null|string|Array.<string>)> | Returns either a dictionary of option names and their corresponding widget input values or just a single widget input value, depending on the amount of passed arguments.

#### inherited getOption(option){null|LuCI.form.AbstractValue|Object.<string, LuCI.form.AbstractValue>}

form.js, line 1197

  Obtain underlying option objects.

  This function is sensitive to the amount of arguments passed to it; if no option name is specified, all options within this section are returned as a dictionary.

  If an option name is supplied, this function returns the matching LuCI.form.AbstractValue instance only.

  Name | Type | Description
  --- | --- | ---
  `option` | string | optional The name of the option object to obtain

  ##### Returns:

  Type | Description
  --- | ---
  null | LuCI.form.AbstractValue | Object.<string, LuCI.form.AbstractValue> | Returns either a dictionary of option names and their corresponding option instance objects or just a single object instance value, depending on the amount of passed arguments.

#### inherited getUIElement(section_id, option){null|LuCI.ui.AbstractElement|Object.<string, (null|LuCI.ui.AbstractElement)>}

form.js, line 1167

  Obtain underlying option LuCI.ui widget instances.

  This function is sensitive to the amount of arguments passed to it; if only one argument is specified, the LuCI.ui widget instances of all options within this section are returned as a dictionary.

  If both the section ID and an option name are supplied, this function returns the LuCI.ui widget instance value of the specified option only.

  Name | Type | Description
  --- | --- | ---
  `section_id` | string | The configuration section ID
  `option` | string | optional The name of the option to query

  ##### Returns:

  Type | Description
  --- | ---
  null | LuCI.ui.AbstractElement | Object.<string, (null|LuCI.ui.AbstractElement)> | Returns either a dictionary of option names and their corresponding widget input values or just a single widget input value, depending on the amount of passed arguments.

#### inherited load(){Promise.<void>}

form.js, line 916

  Load the configuration covered by this section.

  The `load()` function recursively walks the section element tree and invokes the load function of each child option element.

  ##### Returns:

  Type | Description
  --- | ---
  Promise.<void> | Returns a promise resolving once the values of all child elements have been loaded. The promise may reject with an error if any of the child elements' load functions rejected with an error.

#### inherited option(optionclass, classargs){LuCI.form.AbstractValue}

form.js, line 1029

  Add a configuration option widget to the section.

  Note that `taboption()` should be used instead if this form section element uses tabs.

  Name | Type | Description
  --- | --- | ---
  `optionclass` | LuCI.form.AbstractValue | The option class to use for rendering the configuration option. Note that this value must be the class itself, not a class instance obtained from calling `new`. It must also be a class derived from `LuCI.form.AbstractSection`.
  `classargs` | * | repeatable Additional arguments which are passed as-is to the constructor of the given option class. Refer to the class specific constructor documentation for details.

  ##### Throws:

  Throws a `TypeError` exception in case the passed class value is not a descendant of `AbstractValue`.

  Type
    TypeError

  ##### Returns:

  Type | Description
  --- | ---
  LuCI.form.AbstractValue | Returns the instantiated option class instance.

#### inherited parse(){Promise.<void>}

form.js, line 945

  Parse this sections form input.

  The `parse()` function recursively walks the section element tree and triggers input value reading and validation for each encountered child option element.

  Options which are hidden due to unsatisfied dependencies are skipped.

  ##### Returns:

  Type | Description
  --- | ---
  Promise.<void> | Returns a promise resolving once the values of all child elements have been parsed. The returned promise is rejected if any parsed values do not meet the validation constraints of their respective elements.

#### stabilizeActionColumnWidth()

form.js, line 2979

  Ensure the actions column keeps a stable width even when rows are hidden (e.g., due to filtering). Measures the widest actions cell and applies a fixed width to header/filter/footer/action cells. Stores measured width in dataset so filtering won't collapse the column if all rows are hidden.

#### inherited stripTags(s){string}

form.js, line 296

  Strip any HTML tags from the given input string, and decode HTML entities.

  Name | Type | Description
  --- | --- | ---
  `s` | string | The input string to clean.

  ##### Returns:

  Type | Description
  --- | ---
  string | The cleaned input string with HTML tags removed, and HTML entities decoded.

#### inherited tab(name, title, description)

form.js, line 2619

  The `TableSection` implementation does not support option tabbing, so its implementation of `tab()` will always throw an exception when invoked.

  Name | Type | Description
  --- | --- | ---
  `name` | string | The name of the tab to register. It may be freely chosen and just serves as an identifier to differentiate tabs.
  `title` | string | The human readable caption of the tab.
  `description` | string | optional An additional description text for the corresponding tab pane. It is displayed as a text paragraph below the tab but before the tab pane contents. If omitted, no description will be rendered.

  ##### Throws:

  Throws an exception when invoked.

#### inherited taboption(tabName, optionclass, classargs){LuCI.form.AbstractValue}

form.js, line 1066

  Add a configuration option widget to a tab of the section.

  Name | Type | Description
  --- | --- | ---
  `tabName` | string | The name of the section tab to add the option element to.
  `optionclass` | LuCI.form.AbstractValue | The option class to use for rendering the configuration option. Note that this value must be the class itself, not a class instance obtained from calling `new`. It must also be a class derived from `LuCI.form.AbstractSection`.
  `classargs` | * | repeatable Additional arguments which are passed as-is to the constructor of the given option class. Refer to the class specific constructor documentation for details.

  ##### Throws:

  - Throws a `ReferenceError` exception when the given tab name does not exist.

    Type
      ReferenceError

  - Throws a `TypeError` exception in case the passed class value is not a descendant of `AbstractValue`.

    Type
      TypeError

  ##### Returns:

  Type | Description
  --- | ---
  LuCI.form.AbstractValue | Returns the instantiated option class instance.

#### inherited titleFn(property, fmt_args){string|null}

form.js, line 335

  Format the given named property as a title string.

  This function looks up the given named property and formats its value suitable for use as an element caption or description string. It also strips any HTML tags from the result.

  If the property value is a string, it is passed to `String.format()` along with any additional parameters passed to `titleFn()`.

  If the property value is a function, it is invoked with any additional `titleFn()` parameters as arguments, and the obtained return value is converted to a string.

  In all other cases, `null` is returned.

  Name | Type | Description
  --- | --- | ---
  `property` | string | The name of the element property to use.
  `fmt_args` | * | repeatable Extra values to format the title string with.

  ##### Returns:

  Type | Description
  --- | ---
  string | null | The formatted title string or `null` if the property did not exist or was neither a string nor a function.