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

Filtering #27

Open
spacebiscuit opened this issue Dec 8, 2016 · 3 comments
Open

Filtering #27

spacebiscuit opened this issue Dec 8, 2016 · 3 comments

Comments

@spacebiscuit
Copy link

spacebiscuit commented Dec 8, 2016

I'm developing a branch with some modifications and whilst testing the filtering I think I have discovered an error. The component builds OR and AND condititions. I'm not really sure what the need for the AND condition is but it looks to be set as follows:

if ($this->_tableName == $association) {
     $this->config('conditionsAnd', $condition); // merges
} else {
     ....
 }

So any columns of the base table which are searchable will be applied as AND's. This pretty much ensures that no results can ever be returned after filtering. This is in addition to the OR condition that is always built in addition and which results in a complex conditional statement which won't ever in reality be matched.

For example consider this condition which is generated as a result of 4 simple columns,

WHERE      ( 
                      listings.id LIKE :c1 
           AND        listings.description LIKE :c2 
           AND        listings.location LIKE :c3 
           AND        ( 
                                 listings.description LIKE :c4 
                      OR         listings.location LIKE :c5) 
           AND        ( 
                                 listings.description LIKE :c6 
                      OR         listings.location LIKE :c7

This looks to be the work of the original author and not this fork so likely this feature hasn't ever worked.
Could you confirm that my finding is correct and I've not missed something.

TY!

@ypnos-web
Copy link
Owner

ypnos-web commented Dec 9, 2016

I once reworked the condition stuff and tested it. It worked properly back then and I never changed anything afterwards. The And-conditions always match the respective column only and not all columns.

The call to per-column filtering (*) is:
$this->_addCondition($column['name'], $column['search']['value']);

However, the call for the global filter is:
$this->_addCondition($column['name'], $globalSearch, 'or');

It is simply not true that searchable columns are accumulated in conditionsAnd. They are accumulated in conditionsOr.

(*) Per-column filtering is this feature: https://datatables.net/examples/api/multi_filter.html

@spacebiscuit
Copy link
Author

Hi - thanks for the clarification. I actually had not seen the column search feature before reading your reply. This has cleared up a lot of the issues I had been experiencing, initially I had mis-understood what the component was doing it's now clear to see.

So I've now managed to get this working, my implementation working fully. It actually only uses your DataTables component file with some modifications so that the variables I send are correctly mapped to the methods of the component. This approach doesn't require the helper of your plugin since I'm using Angular for the front-end generation.

Should I create a Branch for my implementation? Also happy to create the readme to show how this can be setup.

@ypnos-web
Copy link
Owner

Yes that would be a nice thing to do. I am sure other users of Cake + Angular would be interested.

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

2 participants