Skip to content

feat(table): expose filter and tableColumns for programmatic use#1513

Merged
mlmoravek merged 2 commits intooruga-ui:developfrom
DavidVanDeursen:feature/table/expose-filters-and-columns
Jan 14, 2026
Merged

feat(table): expose filter and tableColumns for programmatic use#1513
mlmoravek merged 2 commits intooruga-ui:developfrom
DavidVanDeursen:feature/table/expose-filters-and-columns

Conversation

@DavidVanDeursen
Copy link
Contributor

@DavidVanDeursen DavidVanDeursen commented Jan 14, 2026

Fixes #1512

Proposed Changes

This PR adds the tableColumns and filters properties to the defineExport so they can be used programmatically.

Possible downsides are that you can set a filter for a column which is not explicitly marked as filterable, and that a warning is thrown when trying to assign a text value to a numeric column.

Example usage:

This snippet allows you to filter on all the columns at the same time using a different input field.

<script setup lang="ts">
import type { TableColumn } from "@oruga-ui/oruga-next";
import { ref } from "vue";

const data = [
    {
        first_name: "Jacobs",
        last_name: "Simmons",
    },
    {
        first_name: "John",
        last_name: "Jacobs",
    },
    {
        first_name: "Tina",
        last_name: "Gilbert",
    },
    {
        first_name: "Clarence",
        last_name: "Flores",
    },
    {
        first_name: "Anne",
        last_name: "Lee",
    },
];

const columns: TableColumn<(typeof data)[number]>[] = [
    {
        field: "first_name",
        label: "First Name",
        filterable: true,
    },
    {
        field: "last_name",
        label: "Last Name",
        filterable: true,
    }
];

const table = ref();

function updateSearch(value) {
    table.value.columns.map((column) => {
        table.value.filters[column.field] = value;
    });
}
</script>

<template>
    <section>
        <o-input @update:model-value="updateSearch" />
        <o-table ref="table" :data="data" :columns="columns" />
    </section>
</template>

This snippet allows you to set a default filter value for one of the columns:

<script setup lang="ts">
import type { TableColumn } from "@oruga-ui/oruga-next";
import { onMounted, ref } from "vue";

const data = [
    {
        first_name: "Jacobs",
        last_name: "Simmons",
    },
    {
        first_name: "John",
        last_name: "Jacobs",
    },
    {
        first_name: "Tina",
        last_name: "Gilbert",
    },
    {
        first_name: "Clarence",
        last_name: "Flores",
    },
    {
        first_name: "Anne",
        last_name: "Lee",
    },
];

const columns: TableColumn<(typeof data)[number]>[] = [
    {
        field: "first_name",
        label: "First Name",
        filterable: true,
    },
    {
        field: "last_name",
        label: "Last Name",
        filterable: true,
    }
];

const table = ref();

onMounted(() => {
    table.value.filters['first_name'] = 'Anne'
})

</script>

<template>
    <section>
        <o-table ref="table" :data="data" :columns="columns" />
    </section>
</template>

@netlify
Copy link

netlify bot commented Jan 14, 2026

Deploy Preview for oruga-documentation-preview ready!

Name Link
🔨 Latest commit f3ca955
🔍 Latest deploy log https://app.netlify.com/projects/oruga-documentation-preview/deploys/6967b48eb25703000885bd6f
😎 Deploy Preview https://deploy-preview-1513--oruga-documentation-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@mlmoravek mlmoravek changed the title feature(table): expose filter and tableColumns for programmatic use. feat(table): expose filter and tableColumns for programmatic use Jan 14, 2026
@DavidVanDeursen DavidVanDeursen force-pushed the feature/table/expose-filters-and-columns branch from 8ff1025 to fe2e4b5 Compare January 14, 2026 15:03
@mlmoravek mlmoravek added the enhancement Improvements to existing features and functionality label Jan 14, 2026
@mlmoravek mlmoravek merged commit 02e6284 into oruga-ui:develop Jan 14, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improvements to existing features and functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose table columns and filters for programmatic usage.

2 participants