matfish2 / vue-tables

Vue.js grid components
https://www.npmjs.com/package/vue-tables
MIT License
357 stars 76 forks source link

Filters initial values #113

Closed popozhu closed 8 years ago

popozhu commented 8 years ago

Hi, I have a problem when using the same key(eg: 'mykey') both in options.params['mykey'] and customFilters: ['mykey'] with these steps below:

As far as I can tell, after the first request, vuetable will call initServerFilters to init customFilters and I don't think this is needed here, because registerServerFilters will do the same jobs in READY phase.

ref:

I'm confused by these two functions, is there something I have missed?

matfish2 commented 8 years ago

init-server-filters is responsible for creating the initial array of customQueries when the plugin in ready. register-server-filters, on the other hand, is registering the listeners and corresponding handlers for each of those queries. So, I don't see any unnecessary duplication.

params should not receive the same key name as in customFilters. The former is supposed to be used for immutable data, while the latter depends on user input.

popozhu commented 8 years ago

Thanks for your patience :)

Well, maybe it's better to make vue-tables compatible with this case...

In my case (params and customFilters have the same key), I have remove the init-server-filters, then it becomes:

matfish2 commented 8 years ago

I am not entirely clear as to why you would need such a cumbersome solution. As I explained params and customFilters serve two distinct purposes and should not be confused. SInce both are sent along with the request it is important not to have naming collisions.

If I understand correctly you are trying to give the filters an initial value. This is a feature I will probably implement in the near future, as a separate option which will address all filter types (generic filter, by column filters and custom filters) and allow the consumer to populate them in advance with an initial value other than an empty string.

popozhu commented 8 years ago

If I understand correctly you are trying to give the filters an initial value.

YES!! You are right.

matfish2 commented 8 years ago

I've added filtersInitialValues. See Options API for usage. Let me know if there are any problems.

popozhu commented 8 years ago

Great and so many thanks !!

Works as expected now.