Skip to content

Improvement custom text filter #572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

madeinfree
Copy link
Contributor

This PR want to resolve #548 and #470 problem, I exposed the filterHandler by onCustomHandleTextFilter api.

First

options: onCustomHandleTextFilter(filter :filterHandler, value :defaultValue)

set onCustomHandleTextFilter props in your TableHeaderColumn like

function customHandleTextFilter(filter, value) {
  // dynamic params
  filter(value, 'TextFilter');
}

<BootstrapTable data={ products }>
  <TableHeaderColumn dataField='id' isKey={ true }>Product ID</TableHeaderColumn>
  <TableHeaderColumn dataField='name' filter={ { type: 'TextFilter', delay: 1000, defaultValue: window.location.hash, customHandleTextFilter: customHandleTextFilter } }>Product Name</TableHeaderColumn>
  <TableHeaderColumn dataField='price'>Product Price</TableHeaderColumn>
</BootstrapTable>

Second

options: clearFilter :boolean
if you set

<TableHeaderColumn dataField='name' filter={ { type: 'TextFilter', clearFilter: true } }>Product Name</TableHeaderColumn>

then TextFilter will auto clear, when you after typed.

@AllenFang
Copy link
Owner

thanks @madeinfree, I'm busy on my job, I'll review it in next weekend. 👍

@madeinfree
Copy link
Contributor Author

@AllenFang, thanks for your effort Allen, when you have some features wanna to do or something needed, feel free to assign me :D

@AllenFang
Copy link
Owner

thanks you very much. I'll tell you on slack :)

@madeinfree
Copy link
Contributor Author

@AllenFang OK, Welcome 👍🏻

@AllenFang
Copy link
Owner

AllenFang commented Aug 9, 2016

@madeinfree, About #470, #595 has tackled it, actually, the requirement for #470 is hope to clean all the filter programmatically, so I think the auto clear is not a well idea and it will make user feel the inconsistency on the data if filter cleaned. Anyway, I'll remember this auto clear mechanism, if someone ask, I can just apply your branch.

And #548, still the same condition, user hope we can provide a mechanism that could be called to apply the filter condition programmatically, so that's why he said the defaultValue only work on init phase. for this issue, I'll try to follow #595's way to implement for all the filter, not only text filter.

So close this PR. Anyway,
because you help me a lots on this project, so I've added your name to my appreciation list on README.md after v2.4.0.

Thanks your contribution :) Hope you can keep to contribute this repo 👍

@AllenFang AllenFang closed this Aug 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to set text value in TextFilter component?
2 participants