# TableAdvanced — SvelteKit UI

Package: sveltekit-ui 1.1.94

Page: https://www.sveltekit-ui.com/components/table_advanced

Category: Data & content

Builds a dynamic and extendable table layout with editable rows/columns, sorting, pagination, bulk-selection, inserting rows, uploading bulk rows, exporting CSV/JSON, and more.

Public component import: `TableAdvanced`

Public manager import: `create_table_advanced_manager`

## Usage

```svelte
<script>
  // Import the shared stylesheet once in your application's root layout.
  import "sveltekit-ui/style.css"
  import { TableAdvanced, create_table_advanced_manager } from "sveltekit-ui"

  const rows = [
    { name: "Website", status: "In review" },
    { name: "Documentation", status: "Draft" },
    { name: "Mobile app", status: "Published" },
  ]

  const manager = create_table_advanced_manager({
    table_name: "Projects",
    definition_stack: [{ rows }],
    rows_data_from_variable_path: ["rows"],
    is_data_editable: false,
    is_paginate: true,
    rows_per_page: 2,
    nav_items: ["search", "pagination", "rows_per_page", "file"],
    columns: {
      name: {
        display_order: 1,
        header_content: { type_id: "base_text", attributes: { content: "Project" } },
        body_content: {
          type_id: "base_text",
          attributes: { content_from_variable_path: ["rows", ["row_i"], "name"] },
        },
      },
      status: {
        display_order: 2,
        header_content: { type_id: "base_text", attributes: { content: "Status" } },
        body_content: {
          type_id: "base_text",
          attributes: { content_from_variable_path: ["rows", ["row_i"], "status"] },
        },
      },
    },
  })
</script>

<TableAdvanced {manager} />
```

## Configuration

### `table_id`

- type: string
- default: null
- description: An optional unique identifier for the table.

### `table_name`

- type: string
- default: null
- description: A display name for the table.

### `table_description`

- type: string
- default: null
- description: A descriptive text for the table.

### `rows_data_from_variable_path`

- type: array of strings or nested arrays
- default: null
- description: Specifies a path to retrieve the rows array within your variable/loop structure. Example: `['variables','data','my_table_rows']`.

### `row_input_content`

- type: ASTC (abstract content) or null
- default: null
- description: Defines the content structure for editing/creating each row.

### `variables_data_type`

- type: object
- default: null
- description: An optional data-type scheme for advanced usage. Typically derived from overall JSON data type.

### `is_data_editable`

- type: boolean
- default: false
- description: If true, enables editing features for rows, columns, and bulk insert/delete.

### `nav_items`

- type: array of strings
- default:
- allowed_values:
  - settings
  - search
  - insert
  - file
  - bulk_select
  - sort_by
  - pagination
  - rows_per_page
  - load_more
- description: Select which interactive elements appear above the table. For instance, 'search', 'file' (export options), 'insert', 'bulk_select', etc.

### `is_paginate`

- type: boolean
- default: false
- description: If true, includes pagination controls.

### `is_more_to_load`

- type: boolean
- default: false
- description: Toggles the 'Load More' button visibility if some server-based pagination still has more rows to fetch.

### `table_header_max_height`

- type: number or null
- default: null
- description: Optional maximum height (in rem) for the table header cells. Contents become scrollable if exceeded.

### `table_row_max_height`

- type: number or null
- default: null
- description: Optional maximum height (in rem) for table body cells. Contents become scrollable if exceeded.

### `columns`

- type: object of { [column_id]: column_definition }
- default:
- description: A dictionary of columns. Each column_id has metadata including `header_content`, `body_content` ASTC for the table header / cell rendering, plus optional properties like min_width, alignment, etc.

### `on_event`

- type: function or null
- description: A callback that intercepts table events (insert/delete row, insert/delete column, load more, update row, bulk delete, etc.). Should return an object `{ is_success: boolean, ... }`. This is how the table manager interacts with external data storage.

### `on_search_table_row_ids`

- type: function or null
- description: Optional: if columns reference foreign tables, you can pass a function for searching row IDs from other tables.

### `table_options`

- type: object or null
- default: null
- description: Optional higher-level table config references, e.g. for specialized column input behavior or server-based queries.

### `mapkit_js_token`

- type: string or null
- default: null
- description: If any columns or row content uses map-based location input, you'll need this MapKit token.

### `rows_per_page`

- type: number
- default: 100
- description: Default rows per page when `is_paginate` is true.

## Methods

### `init()`

- description: Called once to initialize internal managers (popovers, text input, etc.) and set up columns/rows from config.

### `set_attributes()`

- description: Allows dynamic updating of key attributes (like columns, row data path, is_data_editable, etc.) after creation.

### `set_rows_prepped()`

- description: Re-builds rows_prepped from the current columns_prepped and the raw data at `rows_data_from_variable_path`.

### `set_columns_prepped()`

- description: Re-builds columns_prepped from a new columns object. Also re-applies display_order and content managers.

### `set_table_search_text_input()`

- description: Helper to set the search box value programmatically.

### `copy_json()`

- description: Copies the full table row data as JSON to the clipboard.

### `copy_structure()`

- description: Copies only the 'structure' of the row data. (Currently same as copy_json, but you can modify to only copy the shape or schema).

### `download_json()`

- description: Downloads row data as a .json file.

### `download_csv()`

- description: Exports row data as CSV for download.

## Returned state

### `nav_items`

- type: array of strings
- description: Processed array for controlling which nav items appear.

### `rows_prepped`

- type: array of row_prepped objects
- description: Internal structure storing data needed for each row's rendering, bulk select checkbox, and content manager references.

### `columns_prepped`

- type: object { [column_id]: column_config }
- description: Processed columns dictionary with each column's content manager (header_content), up-to-date metadata, etc.

### `table_search_text_input_manager`

- type: object
- description: TextInput manager used if 'search' is in nav_items.

### `pagination_manager`

- type: object
- description: Pagination manager used if `is_paginate` is true and 'pagination' is in nav_items.

### `rows_per_page_dropdown_manager`

- type: object
- description: Dropdown manager for changing how many rows per page if 'rows_per_page' is in nav_items.

### `sort_by_input_manager`

- type: object
- description: Handles advanced multi-column sorting selection if 'sort_by' is in nav_items.

### `file_popover_manager`

- type: object
- description: Popover manager for the file menu, controlling export to CSV/JSON or copy to clipboard. Visible if 'file' is in nav_items.

### `insert_popover_manager`

- type: object
- description: Popover manager controlling the Insert dropdown for columns/rows/bulk upload if 'insert' is in nav_items.

### `bulk_select_all_rows_toggle_checkbox_manager`

- type: object
- description: Global checkbox manager for toggling all row checkboxes if 'bulk_select' is in nav_items and table is editable.

### `bulk_delete_rows_popover_manager`

- type: object
- description: A confirmation popover manager for deleting multiple rows if 'bulk_select' is in nav_items.

### `bulk_insert_rows_prepared_data`

- type: array or null
- description: Holds parsed data from the user's JSON/CSV upload for inserting multiple new rows.

### `row_edit_content_manager`

- type: Content manager object
- description: Manager that controls how a row is displayed/edited in a panel popover.

### `column_edit_input_manager`

- type: ColumnInput manager object
- description: Manager that controls how a column is displayed/edited in a panel popover.
