infinite-react icon indicating copy to clipboard operation
infinite-react copied to clipboard

Add selectOptions props for InfitieTablePropColumns

Open ttruefix14 opened this issue 8 months ago • 3 comments

Enhancement Description

It would be great if Infinite Table could do the following: I can implement fields with selectable options by creating custom field type and mapping values in renderValue, but i want to impement SelectFilterEditor so i need my select options in filter. It can be done by adding selectOptions prop to columns and getting this options from column with useInfiniteColumnFilterEditor hook. Code sample:


import {
    useInfiniteColumnFilterEditor,
} from '@infinite-table/infinite-react';
import { Form } from 'react-bootstrap';

export function SelectFilterEditor<T>() {
    const { value, setValue, className, column } =
        useInfiniteColumnFilterEditor<T>();
    return (
        <Form.Select
            className={className}
            value={value === null ? "" : value}
            onChange={(e) => {

                const selectedValue = e.target.value;
                setValue(selectedValue);
            }}
        >
            <option value="">Select</option>
            {column.selectOptions.map(opt => (
                <option key={opt.code} value={opt.code}>
                    {opt.value}
                </option>
            ))}
        </Form.Select>
    );
}

ttruefix14 avatar Apr 18 '25 08:04 ttruefix14

hey @ttruefix14, sorry, just seen this.

So you are proposing a specific code change? Or things have worked out fine for your use-case?

As an aside, we are working on improving our filters and giving people more flexibility in filtering

radubrehar avatar May 20 '25 12:05 radubrehar

hey @ttruefix14, sorry, just seen this.

So you are proposing a specific code change? Or things have worked out fine for your use-case?

As an aside, we are working on improving our filters and giving people more flexibility in filtering

Hi! Thank you for answer! It works fine in my case, but I'm passing non-existing prop selectOptions to column, so it causes TypeScript warnings, that's why i suggest adding selectOptions prop for columns (or some extraParams prop allowing to pass any custom parameters we need when configuring columns)

ttruefix14 avatar May 20 '25 13:05 ttruefix14

Sounds good! Yes, we'll come up with a more generic way to do this, which should handle more use-cases.

radubrehar avatar May 20 '25 13:05 radubrehar