Closed GoogleCodeExporter closed 9 years ago
Hi,
That sounds like a good idea.
Although I think it can be shorten
$filters->addFilter('field',
array( 'callback' =>
array(
'function' => 'my_callback',
'params' => array('{{filterValue}}')
)
)
);
The callback function should return the SQL to be applied.
Tell me your opinion...
Best Regards,
Bento Vilas Boas
Original comment by pao.fre...@gmail.com
on 13 Feb 2010 at 3:09
Hi,
Do you think
array( 'callback' =>
array(
'function' => ARRAY($this, 'my_callback'),
'params' => array('{{filterValue}}')
)
)
? Or you had something else in mind?
It would give much flexibility. Example
function my_callback($filterValue) {
if ($filterValue == 'January) {
return "aDateTime between '2010-1-1' and '2010-1-31'";
}
}
Maybe even to add field name as a parameter
'params' => array('fieldName', '{{filterValue}}')
function my_callback($fieldName, $filterValue) {
if ($filterValue == 'January) {
return "{{$fieldName}} BETWEEN '2010-1-1' AND '2010-1-31'";
}
}
Maybe this way one callback could be reused?
Original comment by vlatko.b...@gmail.com
on 13 Feb 2010 at 3:27
"
array( 'callback' =>
array(
'function' => ARRAY($this, 'my_callback'),
'params' => array('{{filterValue}}')
)
)
"
Yes, this was my idea.
The callbaclk function should return something like
"AND field >'somehting' ";
Or, in other words, a string to be used in:
$this->_select->where(new Zend_Db_Expr('RESULT_FROM_CALLBACK_FUNCTION'));
Best Regards,
Bento Vilas Boas
Original comment by pao.fre...@gmail.com
on 13 Feb 2010 at 4:27
Also note that there are a few "commands" that can be used in filters to
improve them
http://zfdatagrid.com/grid/site/index/order/Name_ASC/filters/%7B%22filter_ID%22:
%22%3E3000%22,%22filter_Name%22:%22%22,%22filter_CountryCode%22:%22%22,%22filter
_District%22:%22%22,%22filter_Population%22:%22%22%7D
http://zfdatagrid.com/grid/site/index/order/Name_ASC/filters/%7B%22filter_ID%22:
%22347*%22,%22filter_Name%22:%22%22,%22filter_CountryCode%22:%22%22,%22filter_Di
strict%22:%22%22,%22filter_Population%22:%22%22%7D
And others
*value*
*value
value*
>value
>=value
=value
<value
<=value
40<>50 //Numbers between 40 and 50
r:34$ //Will apply a regexp
Best Regards,
Bento Vilas Boas
Original comment by pao.fre...@gmail.com
on 13 Feb 2010 at 4:40
What about the fieldName parameter to callback? Not a good idea?
I know for those filters. :-) I stumbled on them while searching for best way
to do
the filtering.
When can we expect a manual? A draft maybe? Just a few pages? ;-)
Original comment by vlatko.b...@gmail.com
on 13 Feb 2010 at 4:50
Just figured out a nice way to select search for BETWEEN:
(or any other supported search, and there are many :-) )
$period = array(
'2009-11-1 <> 2009-11-31' => 'Nov 2009.',
'2009-12-1 <> 2009-11-31' => 'Dec 2009.',
'2010-01-1 <> 2010-01-31' => 'Jan 2010.',
'2010-02-1 <> 2010-02-31' => 'Feb 2010.',
);
$grid->addFilter('lastAccess', array('values' => $period));
Original comment by vlatko.b...@gmail.com
on 14 Feb 2010 at 8:11
Hi,
First approach.
$filters = new Bvb_Grid_Filters();
$filters->addFilter('field',array('calback'=>'my_callback_function','params'=>ar
ray('optional','params')));
If you print_r() your func_get_args();
you will see something like this by default:
array[0]
['field'] => 'the field that is being filtered'
['value']=>'the value to filter'
['select']=>The select instance. YOU are responsible for apply the
filters using the provided select instance
If you pass any optional argument with $filters->addFilter() they will be
merged.
Original comment by pao.fre...@gmail.com
on 14 Feb 2010 at 6:09
Original comment by pao.fre...@gmail.com
on 16 Feb 2010 at 4:02
Hi
I tried this:
->addFilter('lastname',array(
'callback'=>array($this, 'customFilter'),
'params'=>array('XXX','YYY')
));
but function is not called. Seems this issue is similar to the issue with
converting
object to array. Function can't be called.
Original comment by vlatko.b...@gmail.com
on 16 Feb 2010 at 7:30
Hi,
Sorry. The example above is not correct.
Try this:
$filters->addFilter('lastname',array('callback'=>array('function'=>array($this,
'customFilter'),'params'=>array('XXX','YYY'))));
Best Regards,
Bento Vilas Boas
Original comment by pao.fre...@gmail.com
on 17 Feb 2010 at 1:42
Hi,
it works now.
1. As I see, there is no need for the function to return anything, just to set
the
Where clause of the Select?
2. It would be better if the value "Field" in args is the full name of the field
being filtered, with its table references.
Instead of "name" -> "addressbook.name".
Original comment by vlatko.b...@gmail.com
on 17 Feb 2010 at 9:09
Hi,
Yes. No need to return anything.
I've updated the code. Now table.field instead field
Revision 623
Best Regards,
Bento Vilas Boas
Original comment by pao.fre...@gmail.com
on 17 Feb 2010 at 3:45
Hi,
All works.
Verified.
I'd like to ask you to set the Status of issues I confirmed and verified to
"Verified".
It would be much easier to filter issues in progress.
Original comment by vlatko.b...@gmail.com
on 17 Feb 2010 at 4:04
Original comment by bento.vi...@gmail.com
on 3 Mar 2010 at 4:56
Original issue reported on code.google.com by
vlatko.b...@gmail.com
on 13 Feb 2010 at 9:53