dasDaniel / svelte-table

A svelte table implementation that allows sorting and filtering
https://dasdaniel.github.io/svelte-table/
MIT License
535 stars 40 forks source link

Can you have a placeholder value for the filters if you do not have a search value #144

Closed craigkai closed 1 year ago

craigkai commented 1 year ago

I'd like to have a placeholder value for the search filters but I still only want the input to be a select input and not allow typing in values. I tried adding a value to my filterOptions with a placeholder name and undefined value but that doesn't seem to work:

values.push({
        name: 'all',
        value: undefined
    });
return values;
raja611 commented 1 year ago

Hello @craigkai ,

I understand the problem, the problem is at - https://github.com/dasDaniel/svelte-table/blob/develop/src/SvelteTable.svelte#L319 .

since the first option value is undefined, the filters have no placeholder value if you do not have a search value.

Update the above-mentioned line of code to <option value="All" />

It will give value to filterOptions for the placeholder without any empty value.

Thank you.

dasDaniel commented 1 year ago

I've updated the filterPlaceholder to work on the dropdowns too