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

ComboBox: server-side filtering of the options? #369

Closed
AdrianVasiliu opened this issue Oct 23, 2014 · 6 comments
Closed

ComboBox: server-side filtering of the options? #369

AdrianVasiliu opened this issue Oct 23, 2014 · 6 comments
Assignees
Milestone

Comments

@AdrianVasiliu
Copy link
Contributor

Currently, ComboBox implements the (optional) filtering the options using a filter function executed client-side.

What about server-side filtering, or at least a mechanism allowing the user to implement it?
Requires investigation.

As a side note related with filtering, it might be nice that, if no item matches the query thus the list is empty, the popup shows some specific graphic feedback (to be defined).

@wkeese
Copy link
Member

wkeese commented Oct 23, 2014

I thought ComboBox filtered the options by setting the List's query property, and then List requeries the store. Doesn't that query evaluate on the server automatically, assuming you have a client/server store?

@AdrianVasiliu
Copy link
Contributor Author

It does set List's query property, which triggers delite/Store.computeProperties() which triggers a query on the data store. But it does so (for now) using a filter function:

this.list.query = function (obj) {
    return this._filterFunction(obj[this.list.labelAttr], txt);
}.bind(this);
_filterFunction: function (itemLabel, queryTxt) {
    // TODO: options for case-sensitiveness, startsWith/contains
    // TODO: check fancy locale support...
    queryTxt = queryTxt.toLocaleUpperCase();
    itemLabel = itemLabel.toLocaleUpperCase();
    return itemLabel.indexOf(queryTxt) === 0;
},

https://github.com/ibm-js/deliteful/blob/master/ComboBox.js#L308

The filtering mechanism has been reworked quite a lot in dstore wrt. dojo/store. Since July, dstore has introduced a dstore/Filter API:
https://github.com/SitePen/dstore/blob/v0.2.0/docs/Collection.md#filtering,
https://github.com/SitePen/dstore/blob/v0.2.0/Filter.js

The subject seems still "alive", see dojo/dojo1-dstore#44 or dojo/dojo1-dstore#34.

This might be already the way to go, but whether this is working well for server-side filtering it needs to be checked. The purpose of this issue is precisely to investigate what's the best we can do.

@cjolif
Copy link
Contributor

cjolif commented Nov 7, 2014

dstore/Filter is "just" a way to easily build a filter object. For your case you should probably do something like the following (using regexp):

var filter = new Filter();
list.query = filter.match("label", /abc/);

This will work as-is with dstore/Memory and should work with dstore/Rest if the server is correctly implementing the filtering.

@AdrianVasiliu
Copy link
Contributor Author

Yes. Now, the require of dstore modules has been removed recently from our widgets (Combobox, List). To use the Filter API we'd need to put back a dependency on dstore (for the Filter module itself).

@cjolif
Copy link
Contributor

cjolif commented Nov 7, 2014

Right. An alternate approach is to generate yourself the object that is generated by Filter, Filter is after all just a utility. It should generate something like the following (to be double checked):

list.query = { type: "and", args: ["label", /abc/] }

@AdrianVasiliu AdrianVasiliu added this to the 0.5.0 milestone Nov 19, 2014
@AdrianVasiliu
Copy link
Contributor Author

An alternate approach is to generate yourself the object that is generated by Filter,

As we have seen, this does not seem to do the trick. Hence the use of dstore/Filter in 24e5f71.

AdrianVasiliu pushed a commit that referenced this issue Feb 6, 2015
… server-side filtering (if the data store supports it). Fixes #369
wkeese pushed a commit to wkeese/deliteful that referenced this issue Mar 12, 2015
… server-side filtering (if the data store supports it). Fixes ibm-js#369
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants