AshishJoshi-asj / zfdatagrid

Automatically exported from code.google.com/p/zfdatagrid
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

The way to customize a filter #181

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
What is the expected output? What do you see instead?
I have not find the way to customize a filter column.
I would like to do something like :

->addFilter(<columnName>, array(array('YES', 'NO'), array(0, 1), <searchType>);

Here, 'YES' and 'NO' would be displayed in HTML SELECT element, and values
used to perform the search in DB would be 0 and 1.

Is there a functionality to do that ?
Thanks

What version of the product are you using? On what operating system?
v6.alpha, under Linux Fedora

Please provide any additional information below.

Original issue reported on code.google.com by tribal...@gmail.com on 22 Feb 2010 at 5:48

GoogleCodeExporter commented 9 years ago
Hi,

For Custom values for filters use the values option.

$filters = new Bvb_Grid_Filters();
$filters->addFilter('Name',array('values'=>array('0'=>'No','1'=>'Yes')));
$grid->addFilters($filters);

The search will be performed by the array keys

Best Regards,
Bento Vilas Boas

Original comment by pao.fre...@gmail.com on 22 Feb 2010 at 10:33

GoogleCodeExporter commented 9 years ago
Great !

Thanks

Ideas of improvement : 

1/ for the moment, unless i'm mistaken, I see two cases : either 
Bvb_Grid_Filters()
is used (each columns must be specify if we want all) or filters by default is 
used
(if setNoFilter() is set to 0). It could be practical to combien the both : 
that to
say be able to use default filters (which are specified via setNoFilter(0) and 
whose
search criteria is defined in an updateColumn()) and be able to ADD new or 
replace
exisiting filters through a Bvb_Grid_Filters() without not taking into account
default ones.

2/ use of Zend_Translate for values (displayed labels)

3/ will there be no case where complex array keys (eg. SQL subquery, ...) could 
bring
to an issue ? (just because of the fact that SQL expression used for filter is 
in a
array key ?) If yes, an idea could be to have two arrays in "values" key, one 
for SQL
expressions and the second for labels to display.

4/ use of Bvb_Grid_Filters is pretty cool on a side : if you set two values you 
will
see them in the select whatever the activated filters in the grid. This is not 
the
case when DISTINCT is used to generate the select's items, where with two 
values (for
example) only one is visible when the concerned filter is activated and 'ALL' 
item
does not work (it does not bring back to unfiltered view).

Original comment by tribal...@gmail.com on 23 Feb 2010 at 9:49

GoogleCodeExporter commented 9 years ago
Hi,

1. When using Bvb_Grid_Filters you are explicitly setting definitions for 
filters,
overridden the default procedure.

In my opinion this makes sense.

And setting filters is easy for default input

$filters = new Bvb_Grid_Filters();
$filters->addFilter('one',array());
$filters->addFilter('other');
$filters->addFilter('another');

$grid->addFilters($filters);

2. Done.

3. Not sure if I understood. Example?

Best Regards,
Bento Vilas Boas
4. It's working here http://zfdatagrid.com/grid/site/filters/

Original comment by pao.fre...@gmail.com on 25 Feb 2010 at 12:25

GoogleCodeExporter commented 9 years ago
Hi,

1. Ok, in fact. I thought about a case where a developer will know just some of 
the
field's names, so not all of them : that could bring a problem to use 
addFilter()
method which waits a field name. I will try when moment comes.

2. Ok, thanks

3. It was PHP theory. I will try to find an odd situation (if it exists !)

Original comment by tribal...@gmail.com on 25 Feb 2010 at 9:22

GoogleCodeExporter commented 9 years ago

Original comment by bento.vi...@gmail.com on 3 Mar 2010 at 4:56