Is it possible to specify a default search text as a prop? So far I have tried overriding the MTableToolbar component with a searchText prop as well as an onSearchChanged function to update the state, though it doesnt filter the data until after I have typed
I'm also looking for exactly this. I would be ready to implement this and open a MR.
I've been also trying to change the search placeholder text. As far as I understand, you could add a components prop to
components={{Toolbar: props => <MTableToolbar {...props} searchPlaceholder="Your text"/>}}
Or your could try to change localization prop, but I couldn't get any to work.
Overriding components: https://material-table.com/#/docs/features/component-overriding
Props: https://material-table.com/#/docs/all-props
Actually just found out that when you try to change localization prop, like this:
<MaterialTable
localization={{
toolbar: {
searchPlaceholder: "Your search placeholder"
},
}}
/ >
An error occurred, saying that body.deleteToolTip was undefined, so I gave it its default value, like so and it worked:
<MaterialTable
localization={{
toolbar: {
searchPlaceholder: "Your search placeholder"
},
body: {
deleteTooltip: "Delete"
}
}}
/>
@mumispb This isn't was I was looking for. I'm looking to set search value prop that will actually apply the filter when the prop is changed. This is so that the search value could be loaded from a URL query param.
Setting defaultFilter in for a column in the columns prop works in the desired way (i.e. the filter gets applied when the prop is changed). I would need the same functionality for the search field.
Hi guys, any updates on this? I am looking for the same thing - a default search text I can pass as a prop that actually gets applied.
For anyone interested - I have just opened a PR: #1137
@a544jh I'd recommend to open new issues for unrelated problems, do not mix topics please, it's confusing.
I think this can be closed since #1225 was merged.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You can reopen it if it required.
Most helpful comment
@mumispb This isn't was I was looking for. I'm looking to set search value prop that will actually apply the filter when the prop is changed. This is so that the search value could be loaded from a URL query param.
Setting
defaultFilterin for a column in thecolumnsprop works in the desired way (i.e. the filter gets applied when the prop is changed). I would need the same functionality for the search field.