asa
asa

Reputation: 641

Set default value to filter

I am doing a React Dashboard using the React-Admin framework, and I would like to set on this :

<BooleanInput source="existe" alwaysOn />

I tried things like :

<BooleanInput source="existe" defaultValue={true} alwaysOn />

But it doesn't work at all, can someone help me ?

Upvotes: 3

Views: 3432

Answers (2)

Nghia Pham Tuan
Nghia Pham Tuan

Reputation: 109

Your filter should look like:

const YourFilter = (props) => (
    <Filter {...props}>
        <BooleanInput source="existe" alwaysOn />
    </Filter>
);

And your <List> props should look like:

<List {...props} filters={<YourFilter />} filterDefaultValues={{ existe: true }}>

Upvotes: 3

asa
asa

Reputation: 641

Ok I was just a bit stupid I think, I just have to set in my <List> component the property :

filterDefaultValues={{ existe: true }}

Upvotes: 9

Related Questions