Cinder.Filters.MultiSelect (Cinder v0.5.0)

View Source

Multi-select tag-based filter implementation for Cinder tables.

Provides multiple selection filtering with a modern dropdown + tags interface. Selected items are displayed as removable tags with a dropdown for adding new selections. Uses Phoenix LiveView patterns for interactivity.

Match Mode Options

The match_mode option controls how multiple selections are combined:

  • :any (default) - Shows records containing ANY of the selected values (OR logic)
  • :all - Shows records containing ALL of the selected values (AND logic)

Examples

# ANY logic - show books with at least one selected tag
<:col field="tags" filter={:multi_select}
      filter_options={[
        options: [{"Fiction", "fiction"}, {"Romance", "romance"}],
        match_mode: :any
      ]} />

# ALL logic - show books that have all selected tags
<:col field="tags" filter={:multi_select}
      filter_options={[
        options: [{"Fiction", "fiction"}, {"Bestseller", "bestseller"}],
        match_mode: :all
      ]} />

Array Field Support

This filter automatically detects array fields and uses containment logic:

  • For array fields: "selected_value" in array_field
  • For non-array fields: field in [selected_values]

The match_mode option only affects array fields. For non-array fields, standard IN operator logic is always used regardless of match_mode.

Summary

Functions

Handles toggling an option in the multi-select filter.

Functions

handle_toggle_option(socket, field, value)

Handles toggling an option in the multi-select filter.

This function should be called from the parent LiveView/LiveComponent to handle the "toggle_multiselect_option" event.