APY/APYDataGridBundle

add date column filter

Closed this issue · 67 comments

add date column filter

What to you want to do with this filter?

When you add a Enhancement or Feature, please give us a little description. We can help you.

just date column in not rendering any filter in renderFilter function ... there should be a input or few selects like in form data widget

  • Set a Range of date with inputs text
  • Set a Range of date with selects
  • Set a Date with inputs text
  • Set a Date with selects

What can we choose as a solution?
Add a different type for these solutions ? DateRangeInput, DateRangeSelect, DateInput, DateSelect?

all of them :) ... we can add annotation options like range=true, mode="input/select"

It gets complicated :(

but Set a Range of date with inputs text will be enough

maybe its not so difficult ... i'm planing to use form component transformers

Any news about this feature ?

what do you mean with "form component transformers" ?
i'm also interested in a date column filter.

I'm also working on a fork to add the possibility to select an operator for each filter ("like", "not like", "equal", "not equal", ...).

For filters, do you have tested this common tricks in filter fiedl ?
<value | =value | >value | <=value | >=value | value | value | value | <>value | value1,value2,... | number<>number
Or regex ?

i was thinking about regexp but as i remember there was no regexp support in doctrine during source class creation, i would prefer operators instead of keywords

there is support for operators in source class but input string need to be properly parsed in column during filter creation

Actually I was thinking on a second select, containing different operators, depending on column type.

For exemple :

  • select column would have those operators: equal, different
  • text column: equal, different, containing, not containing, starting with, ending with
  • numeric column (ToDo): equal, different, lower, lower or equal, greater, greater or equal
  • date column: equal, different, after, before

Good exemples, I like your ideas.
With a select, you can handle integers, dates too and a multiple selection.

@S0RIEN do you have already started the dev of these features?

nop, don't have much time for this.. :(

Are you working on the daterange filter at the moment? if so, I'd happily test it, and of course help if at all possible - I'm after a data grid component for sf2 that can do date range filtering, and am reluctant to start writing my own (especially seeing there's already something like this bundle).

Not yet. @sterrien do you want to implement it?

The date filter would be great if implemented.

I can try to do it. But not until wednesday ;-)

Thanks sterrien. I'll try to do the export - or not - this week end.

Hi guys, I am user of this bundle which is very well done and help me a lot. I am therefore very interested in the resolution of the search by range of date. Is this still in the pipeline ? I have a project to deliver within the next few days and it's a pain in the ass for me too. Thanks in advance for your help.

@sterrien any news ?

Nop, sorry. I don't have time these days.

@dazealot seeing as sterrien is busy, do you want to get in touch with me? Maybe between the two of us, and with a little help/information from abhoryo, we can tackle implementing that particular feature ourselves. Next week I will have to deliver a first working version of the project I'm currently working on, and I'm 100% certain that date range filtering of the data will be among the very first things my manager will want added.

I think you have to look at the RangeColumn class.
In the DateColumn class, you have to deal with the format of :

Thanks @sterrien - so, if I understand this correctly, we will basically need to grasp what RangeColumn and DateColumn are doing exactly and how, then create a DateRangeColumn class, and deal with the formats and conversions thereof. Sound about right? I suppose the DateTimeToLocalizedStringTransformer that @S0RIEN mentioned will come in handy there at some point somewhere.

@userfriendly I would like to help you in this but I don't think I don't have the capability to do a such thing, dates are relay a pain in the ass to deal with... Now a days it is mandatory that a dataGrid as date rang filtering.

I've added DateTimeRange (datetimerange) and DateRange(daterange) columns with intputs.

Values are automatically displayed in locale date/datetime format.
Filter manage everything that a DateTime instance can understand. (2012-04-02, Apr 6, 2012, -6 weeks, next Monday 2012-05-01, `first monday of January 2012 ...)

Enjoy.

so first of all thank you very much for the job. I've tried it on one of my DateTime column so i've pute --> type="datetimerange" in the grid annotation and now I have a error message concerning the local value.

An exception has been thrown during the rendering of a template ("The Symfony\Component\Locale\Stub\StubIntlDateFormatter::__construct() method's argument $locale value 'fr' behavior is not implemented. Only the 'en' locale is supported. Please install the 'intl' extension for full localization capabilities.") in RaligneBaseBundle::layout.html.twig at line 18. 

You have this error because INTL(ICU) extension is not activated or installed in your PHP. So by default Symfony manage only the locale 'en'.

I can perhaps add a fallback for users who have not the intl extension activated.

I've added DateTime (datetime) and Date (date) columns too.

@mdm1290 do you want a fallback with a format attribute like the old dateColumn ?

I've try to add a Time and TimeRange column but I don't know how to extract the time of a DQL datetime. Does anyone know?

okok my bad, I've activated them now and stile have an error while the rendering of the datagGrid,

Fatal error: Call to a member function format() on a non-object in C:\workspace\raligne\vendor\bundles\Sorien\DataGridBundle\Grid\Column\DateTimeRangeColumn.php on line 76
Call Stack

@Abhoryo yes why not because the us format isn't really used else where than in the states lol

locale="en" is set in parameter.ini?

translator: { fallback: %locale% } is uncommented in config.yml ?

Close your webBrowser and clear your cache.

Everything is green on this page http://localhost/Symfony/web/config.php -> re-check configuration ?

Yes locale="en" is set

If i uncomment the translator line in config.yml it doesn't change anything and my translations don't work anymore

Can you debug the $formatter variable?

I have the head columns displayed but i have the error while rendering the row so I can't debug anything

Can you try an error_log('class: '.get_class($formatter)); on line 75 of DateTimeRangeColumn.php ? And open your error.log file

I've aded the line and I don't have any error.log in folder logs

From what I found on the web this is definitely a problem of the intl extension installation.

Do you use easyPHP or WampServer on Windows ?
Do you have in your PATH variable system the directory where the files icu*.dll of PHP are ?
Can you look at the php error log file, maybe it tells you that this extension doesn't work because of something.

I've aded the line and I don't have any error.log in folder logs

the log folder of your server not the folder log of symfony.

I use WampServer, I don't have the path in my system variables when I go in the php_error.log it is empty

With WampServer you have to append the directory path of these icu*.dll files in the PATH variable system of Windows and close and restart Wampserver.

I'll try tomorrow to add a force format.

okay so now I added the path C:\wamp\bin\php\php5.3.10\icu*.dll to my variable system and I stile have the same problem

Ne mets pas icu*.dll juste le répertoire. Et relance ton Pc.

ah alors j'avais déjà une variable d'environement path pointant sur C:\wamp\bin\php\php5.3.10;

Oki je suis à cours d'idée. Sur easyPhp marche directement. Bref je vais remettre le paramètre format.

Okay je vais test avec easyPhp alors.

Si jamais j'ai une autre erreur depuis que j'ai mis à jours le bundle. Lorsque j'utilise le filtre pour une column de type text j'ai se message d'erreur qui vient.

An exception has been thrown during the rendering of a template ("Notice: Undefined offset: 1 in C:\workspace\raligne\vendor\bundles\Sorien\DataGridBundle\Grid\Source\Entity.php line 187") in RaligneBaseBundle::layout.html.twig at line 12.

J'ai eu la même, il faut faire un cache:clear. En plus je pense que cette fonction ne sert plus à rien vu le système que j'ai rajouté.

I've added the format attribute and add a fallback format.

Trop beau ca marche!!! Merci pour tout!!

mise a part ca j'ai toujours cette erreur

An exception has been thrown during the rendering of a template ("Notice: Undefined offset: 1 in C:\workspace\raligne\vendor\bundles\Sorien\DataGridBundle\Grid\Source\Entity.php line 187") in RaligneBaseBundle::layout.html.twig at line 7. 

j'ai beau clearer le cache et les filtres ne marche toujours pas sur les type text

Le cache:clear c'est bien mais il y a toujours des problèmes dans certains cas car le cache n'est pas vraiment cleared.

Essaie de supprimer tout simplement les répertoires qui se trouvent dans le répertoire cache et ressaie.

Oui je clear toujours le cache à la sauvage si ca marche pas la commande cache:clear
j'ai même

  • supprimé le cache du navigateur.
  • publié les assets
  • réinstallé le bundle

mais rien ne change, l'autre jours un simple cache:clear et c'etais bon mais la...

Hum, cela vient d'un problème de l'utilisation d'une colonne avec pour opérateur un LIKE. Utilises-tu une colonne spécifique que tu as créé toi-même ?

Quelques sont tous les types de tes colonnes ?

J'ai crée aucune colonne spécifique, mise à part la column datetimerange, les autres columns sont de type text. C'est lorsque j'utilise le filtre sur ces columns de type text que ca m'affiche ce message d'erreur. et c'est comme ca sur tout mes grids avec des filtres text

Ok, j'ai compris. Merci, je corrigerai en rentrant ce soir.

Works for me! Merci

C'est possible de mettre un contrôle de saisi sur le filtre des dates? Car la un utilisateur peut rentré n'importe quoi (lettres) et ça fais une erreur.

Ah, j'ai oublié ce cas.

Voilà j'ai ajouté un contrôle. J'espère que le comportement que j'ai appliqué vous conviendra.

Si la valeur d'un filtre ne correspond pas à une date ou datetime, il est ignoré et remis à vide.

Exemple avec un daterange:
Si la personne saisie : From = 2012-04-04 et To = fgzegze Cela sera équivalent à date >= 2012-04-04

Je pourrais bien sûr faire l'inverse et lancer une requête sans résultat du style date >= 2012-04-04 and date <= fgzegze

Bref à vous de me donner votre avis.

Sinon, une petite idée m'est venue. Que pensez-vous d'un filtre dynamique ?
@sterrien a ajouté la possibilité de choisir de l'opérateur du filtre. Ca marche niquel et grâce à ça on peut envisager une autre évolution.

Un filtre de type text(input) qui si on choisit l'opérateur >= ou > fait apparaitre un second input pour faire un range.

De même, quand on choisi l'opératuer = ou like, d'autres inputs apparaissent pour pouvoir filtrer sur plusieurs termes à la fois.

Qu'en pensez-vous ?

Des filtres dynamique serait une bonne évolution du truc, ou des filtres en autocompletion, mais ca c une autre histoire...

Ce que je propose nécessite peu de javascript. L'autocompletion serait complexe car il faut éviter d'utiliser des framework. De plus l'autocompletion se greffe généralement automatiquement donc c'est plus quelque chose à implémenter à côté chacun par ses soins.