Skip to content
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

Add support for simple filtering #255

Closed
marcushellberg opened this issue Nov 11, 2015 · 4 comments
Closed

Add support for simple filtering #255

marcushellberg opened this issue Nov 11, 2015 · 4 comments

Comments

@marcushellberg
Copy link
Member

In order to make it easier to understand how to filter a grid, I would like to see a filter(column, string) method in the API. With an array datasource, it would filter the array and with a function data source it would pass the filter parameter to the function.

@jouni jouni added backlog and removed backlog labels Nov 16, 2015
@Saulis
Copy link
Contributor

Saulis commented Nov 20, 2015

As discussed with @JouniK and @platosha here's a proposal to start working with:

As a first step, add filter property similar to sortOrder to the Column API. Filters could be changed by grid.columns[0].filter = 'foo'; or similar. The could be a helper function added later to insert multiple filters at a time.

When filters have been defined, the params object in the data fetch request would have a filter property. The structure of the object could be either [ { name: 'firstName', filter: 'foo' }, { name: 'lastName', filter: 'bar' }] or for example {firstName: 'foo', lastName: 'bar'}. That would need to be tested out - the main thing is that it should closely resemble the sortOrder object probably.

There would be a public function which would define the filtering method, by default it would a contains type of filtering and that method would be internally used when filtering arrays. It could also be accessed from the function data source and it could be overridden by the user if needed.

When using array data sources, changing the filters would always trigger filtering immediately and fire a filter-changed event. With function data sources, function would be fired, but no data requests would be fired until the user explicitly refreshes the items.

Afterwards, we could design and apply a way how to also add a header row with input fields.

@jouni
Copy link
Member

jouni commented Nov 20, 2015

I would not add a property to the column objects, as we don’t have the sortDirection property there either. I see that it could be there, but I would still start with just one addition filter property on the main grid object:

grid.filter = [
  { 
    column: index/name,
    filter: string/object
  },
  ...
];

The nested filter could be a more complex object for stuff like "greater than" etc.

@kito99
Copy link

kito99 commented May 25, 2016

+1 for having this natively.

@jouni jouni added the 1.x label Nov 8, 2016
@jouni
Copy link
Member

jouni commented Nov 8, 2016

2.0 will have the <vaadin-grid-filter> element that you can use to easily add filters for the columns. See online example.

We won’t fix this for 1.x.

@jouni jouni closed this as completed Nov 8, 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

No branches or pull requests

4 participants