GridViewController

GridViewController

Grid View Controller - Simplified Architecture

This controller follows a clean MVC pattern where:

  • Server generates complete state
  • Templates display state
  • Controller captures user actions and navigates

NO state management in JavaScript - server is source of truth.

Supports optional bulk selection when enableBulkSelection is configured.

Constructor

new GridViewController()

Source:

Methods

applyColumnChanges()

Description:
  • Apply column changes (from modal)

Source:

applyDateRangeFilter()

Description:
  • Apply date range filter

Source:

applySort()

Description:
  • Apply sort to a column

Source:

buildFilterItems()

Description:
  • Build the shared filter-menu items used by navigation and panels.

Source:

buildUrl()

Description:
  • Build URL with updated parameters

Source:

buildUrlWithFilters()

Description:
  • Build URL with filter parameters

Source:

clearAllFilters()

Description:
  • Clear all filters and search (preserves locked filters)

Source:

clearBulkSelection()

Description:
  • Clear all bulk selections

Source:

(async) clearDefault()

Description:
  • Clear user default view

Source:

clearSearch()

Description:
  • Clear search

Source:

connect()

Description:
  • Initialize controller

Source:

createFilterPill(column, value, isLocked)

Description:
  • Create a filter pill element

Source:
Parameters:
Name Type Default Description
column string

The filter column key

value string

The filter value

isLocked boolean false

Whether this filter is locked (cannot be removed)

createSearchBadge()

Description:
  • Create a search badge element

Source:

createViewTab(name, viewId, isActive, isPreferred, canManage, count)

Description:
  • Create a view tab element

Source:
Parameters:
Name Type Default Description
name string

Tab name

viewId string | null

View ID (null for 'All' tab)

isActive boolean

Is this the active tab

isPreferred boolean

Is this the preferred (default) view

canManage boolean

Can this view be managed

count number | null null

Optional count for badge display

(async) deleteView()

Description:
  • Delete current view

Source:

disconnect()

Description:
  • Cleanup when controller disconnects

Source:

escapeHtml()

Description:
  • Escape HTML for safe insertion

Source:

exportCsv()

Description:
  • Export current grid data to CSV

    Triggers a CSV export with current filters, search, sort, and column selection. Uses the table frame's src URL as base (handles embedded grids with custom endpoints).

Source:

formatColumnName()

Description:
  • Format column name for display

Source:

getCsrfToken()

Description:
  • Get CSRF token from meta tag

Source:

getCurrentConfig()

Description:
  • Get current configuration for saving

Source:

getFilterColumnLabel()

Description:
  • Get filter column label from metadata

Source:

getFilterValueLabel()

Description:
  • Get filter value label from metadata

Source:

getSelectedCheckboxData()

Description:
  • Collect data attributes from selected row checkboxes

Source:

handleColumnReorder()

Description:
  • Handle column reorder from sortable list

Source:

handleFrameLoad()

Description:
  • Handle Turbo Frame load - update state from table frame

Source:

handlePopState()

Description:
  • Browser back/forward: sync table frame to URL without pushing history again.

Source:

handleSearchKeyup()

Description:
  • Handle search input keyup with debouncing

Source:

isFilterLocked(column, lockedFilters) → {boolean}

Description:
  • Check if a filter column is locked

Source:
Parameters:
Name Type Description
column string

The filter column key

lockedFilters Array.<string>

Array of locked filter keys

Returns:

True if the filter is locked

Type
boolean

isTruthyDatasetValue()

Description:
  • Interpret HTML data attribute values as booleans for conditional bulk actions.

Source:

loadInlineState()

Description:
  • Load state from inline rendered content (when table frame doesn't have src) This handles the case where grid content is pre-rendered on initial page load.

Source:

mergeStateWithPrevious(nextState) → {object}

Description:
  • Preserve static metadata across table-only refreshes.

Source:
Parameters:
Name Type Description
nextState object
Returns:
Type
object
Description:
  • Navigate to URL via Turbo (frame or full page)

Source:

performSearch()

Description:
  • Perform search

Source:

removeFilter()

Description:
  • Remove a specific filter value

Source:

rowCheckboxElements()

Description:
  • Current row checkbox elements in the live grid DOM.

Source:

(async) saveView()

Description:
  • Save current state as new view

Source:

selectFilter()

Description:
  • Show specific filter panel in dropdown

Source:

selectableRowCheckboxTargets()

Description:
  • Row checkboxes that participate in bulk selection (not bestowal-locked).

Source:

selectedRowCheckboxTargets()

Description:
  • Selected row checkboxes on the current page.

Source:

(async) setDefault()

Description:
  • Set current view as user default

Source:

setSearchBusy()

Description:
  • Toggle search busy indicator in the filter search input.

Source:

showAll()

Description:
  • Show all records (clear view selection)

Source:

switchView()

Description:
  • Switch to a specific view

Source:

toggleAllSelection()

Description:
  • Toggle all row checkboxes on current page

Source:

toggleColumn()

Description:
  • Toggle column visibility (checkbox in modal)

Source:

toggleFilter()

Description:
  • Toggle a filter value

Source:

toggleRowSelection()

Description:
  • Toggle individual row selection checkbox

Source:

toggleSubRow(event)

Description:
  • Toggle sub-row expansion for additional details

Source:
Parameters:
Name Type Description
event Event

Click event from cell with toggleSubRow action

triggerBulkAction()

Description:
  • Trigger bulk action - dispatches event with selected IDs for modal listeners

Source:

updateBulkSelectionUI()

Description:
  • Update bulk action button state and selection count display

Source:

updateClearFiltersFooter()

Description:
  • Update clear filters footer visibility

Source:

updateColumnPicker()

Description:
  • Update column picker modal

Source:

updateDateRangeFilter()

Description:
  • Update date range filter value

Source:

updateFilterCount()

Description:
  • Update filter count badge

Source:

updateFilterDropdownCheckboxes()

Description:
  • Update filter dropdown checkboxes to match current state (This is now mostly redundant since we rebuild the panels, but keeping it for any dynamic checkbox updates)

Source:

updateFilterNavigation()

Description:
  • Update filter navigation (left side filter tabs)

Source:

updateFilterPanels()

Description:
  • Update filter panels (right side filter options)

Source:

updateFilterPills()

Description:
  • Update filter pill display

Source:

updateSearchDisplay()

Description:
  • Update search display

Source:

updateToolbar()

Description:
  • Update toolbar UI based on current state

Source:

(async) updateView()

Description:
  • Update existing view with current state

Source:

updateViewTabs()

Description:
  • Update view tabs from state

Source: