developer.jelix.org is not used any more and exists only for history. Post new tickets on the Github account.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.

Opened 11 years ago

Last modified 8 years ago

#833 confirmed new feature

Add the ability to filter the results on a daocrud list

Reported by: mike Owned by:
Priority: high Milestone:
Component: jelix:controllers Version: 1.1
Severity: minor Keywords: daocrud, filter
Cc: Blocked By:
Blocking: Documentation needed: no
Hosting Provider: Php version:

Description

It would be great if we can filter the results with a form at the top of results. With daocrud all we already have pagination and a lot of good things but this one is missing ;-) Technically we just have to use the same form as the edit form and display only fields the developer want to. I will provide a patch soon, but I'm waiting for your advices or requests !

Attachments (2)

patch_833.diff (9.6 KB) - added by mike 11 years ago.
First version, just to get the idea !
patch_833_1.diff (9.6 KB) - added by mike 11 years ago.
Correcting a mistake in a template

Download all attachments as: .zip

Change History (12)

comment:1 Changed 11 years ago by laurentj

  • Milestone Jelix 1.1.1 deleted

Changed 11 years ago by mike

First version, just to get the idea !

comment:2 Changed 11 years ago by mike

  • review set to review?

comment:3 Changed 11 years ago by mike

Note I hav two things to improve on the previous patch in the _filterSetConditions method :

  • find a more elegant way to check if we just have a form post instead of "if ($this->param('_submit'))"
  • the filter only works with "begin with" style on the addcondition (in SQL : "field LIKE value%"). Maybe this has to be improved with another system to include begin with, end with, is exactly, is greater than, is equal or greater for the numbers, etc...

Changed 11 years ago by mike

Correcting a mistake in a template

comment:4 follow-up: Changed 11 years ago by laurentj

  • Milestone set to Jelix 1.2
  • review changed from review? to review-
  • $propertie -> $property
  • lib/jelix/CREDITS should be updated

About _filterSetConditions:

  • are you sure it is $this->form ? not $this->filterForm ?
  • using LIKE for each property is not good. I think we should get the factory of the dao and call its getProperties method, which gives the datatype for each properties. So we can know at least if we can use "like" (for strings) or "=" (for others). We can also get type of controls : if it is an input then we use LIKE, else we use "=".
  • however, perhaps the best way is to provide the operator we would like, in propertiesForFilter. array('property'=>'operator'). it means that we cannot use propertiesForList by default.
  • if ($this->param('_submit'))" : it is not good because the name of the submit button is not always '_submit'. Or the name of the submit button can be impose..

perhaps we can also improve all your patch, in order to provide a powerfull search form like we have in developer.jelix.org (ticket search): the user can choose the operator himself.

comment:5 in reply to: ↑ 4 Changed 11 years ago by mike

Thank you Laurent for reviewing this ticket. I have been using this filter for 4 months and I had already added some improvements, so I can provide another patch with your modifications.

Replying to laurentj:

  • $propertie -> $property
  • lib/jelix/CREDITS should be updated

Ok no worries for that, I will update this.

About _filterSetConditions:

  • are you sure it is $this->form ? not $this->filterForm ?

Exactly it's filterForm and not just form.

  • using LIKE for each property is not good. I think we should get the factory of the dao and call its getProperties method, which gives the datatype for each properties. So we can know at least if we can use "like" (for strings) or "=" (for others). We can also get type of controls : if it is an input then we use LIKE, else we use "=".

I think it's easy to add this detection.

  • however, perhaps the best way is to provide the operator we would like, in propertiesForFilter. array('property'=>'operator'). it means that we cannot use propertiesForList by default.

I think we can user propertiesForList by default and detect the type to know if it's "=" or "LIKE". If we provide propertiesForFilter we use the operator given.

  • if ($this->param('_submit'))" : it is not good because the name of the submit button is not always '_submit'. Or the name of the submit button can be impose..

I know it's not the good way, it was only to test the functionnality. Do you have something to advice on this point ?

perhaps we can also improve all your patch, in order to provide a powerfull search form like we have in developer.jelix.org (ticket search): the user can choose the operator himself.

Why not! If I can see the code I can take some inspiration!

comment:6 Changed 11 years ago by laurentj

I think we can user propertiesForList by default and detect the type to know if it's "=" or "LIKE". If we provide propertiesForFilter we use the operator given.

I think the problem is that the auto detection could be heavy... Well, I will see your futur patch.

Do you have something to advice on this point ?

no. I have to think about it...

comment:7 Changed 10 years ago by laurentj

  • Milestone changed from Jelix 1.2 beta to Jelix 1.2

any news ?

comment:8 Changed 10 years ago by laurentj

  • Milestone changed from Jelix 1.2 to Jelix 1.3
  • Priority changed from normal to high

comment:9 Changed 9 years ago by laurentj

  • Milestone Jelix 1.3 deleted

comment:10 Changed 8 years ago by laurentj

  • review review- deleted
  • Status changed from new to confirmed
Note: See TracTickets for help on using tickets.