Skip to content

Pre-populated Filter Options #756

Answered by kennsorr
kennsorr asked this question in Q&A
Discussion options

You must be logged in to vote

Found a work around for this. Once the table is created using useMaterialReactTable, the table instance has a setState method available that can be used to toggle/select the filterSelectOptions.

const table = useMaterialReactTable({ 
    ...,
    {
        accessorKey: 'owner',
        header: 'Owner',
        size: 120,
        filterVariant: 'multi-select',
        filterSelectOptions: ['ownerA', 'ownerB', 'ownerC', ...],
    },
    ...,
 });

Child component with table passed in as prop:

useEffect(() => {
  if (dep) {
    table.setState((prevState: MRT_Updater<any>) => {
      columnFilters = [{ id: "owner", value: **newfilterSelectedOptions** }];
          return {
             ...pre…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by kennsorr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant