Page 1 of 1

how to filter the lookup results include in grid widget

PostPosted: Sun May 30, 2010 5:50 am
by olivyeah
Hello,
First of all, many thanks for xataface and support.
My question is how to filter "add existing" searchs results in the lookup widget of the grid widget .
Something like " widget:addexistingfilters = {contact_type: 3}" in the field.ini would be cool!
In HTML\Quickform\grid.php I found :
Code: Select all
jQuery(document).ready(function($){
     $('.xf-lookup-grid-row-button-<?php echo $fieldName;?>').each(function(){
           $(this).RecordBrowser({
               <?php if ($this->addExistingFilters):?>filters: <?php echo json_encode($this->addExistingFilters);?>,<?php endif;?>
               table: <?php echo json_encode($this->table);?>,
               callback: function(values){...

This is what i need but I can't find a clean way to use it simply...
Is someone got an idea?

Related question: the addexisting lookup widget in the grid widget only work if lookup widget is already used with another field , is it a bug or am I wrong with something ? (ver 1.2.4 1811)

thanks

--
oliv

Re: how to filter the lookup results include in grid widget

PostPosted: Sun May 30, 2010 11:08 pm
by shannah
This feature was implemented but never tested yet so it probably doesn't work yet. I'll have to refer to the source code carefully to see how it is intended to work.

As for the lookup not working unless it's also elsewhere on the form, this would appear to be a bug. Thanks for reporting it.

Re: how to filter the lookup results include in grid widget

PostPosted: Sun May 30, 2010 11:18 pm
by shannah
Ok here's the syntax
Code: Select all
[myfield]
...
widget:filters:groupid=10


In this case it would filter the lookup to only show results matching group I'd 10.

Re: how to filter the lookup results include in grid widget

PostPosted: Tue Jun 01, 2010 3:22 am
by olivyeah
Bonjour,
Thanks for your fast answer.
It works on lookup widget but unfortunaly it don't work on the lookup that appear clicking "add existing record" in the grid widget ...

Code: Select all
[artiste_tourneur_contact]
transient = 1
widget:label = "tourneur"
widget:type = grid
widget:filters:contact_type = 3
relationship = tourneur2contact
order = 3


Don't works (lookup is not filtered)

But this works (despite this is not what i need)
Code: Select all
[artiste_tourneur_contact]
transient = 1
widget:label = "tourneur"
widget:type = lookup
widget:table=contacts
widget:filters:contact_type = 3
order = 3



Having an idea ?

best regards

--
oliv

Re: how to filter the lookup results include in grid widget

PostPosted: Sat Jul 31, 2010 4:59 pm
by olivyeah
olivyeah wrote:...
Related question: the addexisting lookup widget in the grid widget only work if lookup widget is already used with another field , is it a bug or am I wrong with something ?
...


Just need to add :

Code: Select all
function block__custom_javascripts(){
         echo '<script type="text/javascript" src="http://eee_oliv/xataface/js/jquery-ui-1.7.2.custom.min.js"></script>';
         echo '<script type="text/javascript" src="http://eee_oliv/xataface/js/RecordBrowser/RecordBrowser.js"></script>';
         echo '<script type="text/javascript" src="http://eee_oliv/xataface/js/RecordDialog/RecordDialog.js"></script>';
   }     

in the table delegate class to have the lookup working in the grid widget.

--
oliv