omusico / zfdatagrid

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

Autocomplete doesn't work - not callable function #768

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Add public function addAutoCompleteToFields in my controller
2.Add listenEvent to my grid = $grid->listenEvent('grid.init_deploy', 
'addAutoCompleteToFields');

What is the expected output? Auto complete fields
What do you see instead? error => Message: addAutoCompleteToFields not callable 

Please insert the appropriate values;
                    Zend Framework version:1.11.11
ZFDatgrid Version (Bvb_Grid::getVersion()):$Rev: 1868 $

I have juste used the code below : http://zfdatagrid.com/grid/default/site/code

Original issue reported on code.google.com by p...@yujia.fr on 30 Sep 2011 at 6:37

GoogleCodeExporter commented 9 years ago
Hi,

$grid->listenEvent('grid.init_deploy', array($this, 'addAutoCompleteToFields'));

Should do the trick

Best Regards,
Bento Vilas Boas

Original comment by bento.vi...@gmail.com on 30 Sep 2011 at 10:13

GoogleCodeExporter commented 9 years ago
Hi,

That works better. But it's seems the url is wrong.
This is my addAutoCompleteToFields function :

public function addAutoCompleteToFields(Bvb_Grid_Event $event)
{
    $subject = $event->getSubject();
    $script = "$(document).ready(function() {";
    foreach ($subject->getVisibleFields() as $name) {
        $script .= "$(\"input#filter_$name\").autocomplete({focus: function(event, ui) "
                 . "{document.getElementById('filter_$name').value = ui.item.value },"
                 . " source: '{$subject->getAutoCompleteUrlForFilter($name)}'});\n";
    }
    $script .= "});";

    $subject->getView()->headScript()->appendScript($script);
}

Thanks for your support, and sorry for my bad english :x

Original comment by p...@yujia.fr on 1 Oct 2011 at 5:49

GoogleCodeExporter commented 9 years ago
Hi,

What is the url generated?

Best Regards,
Bento Vilas Boas

Original comment by bento.vi...@gmail.com on 1 Oct 2011 at 6:10

GoogleCodeExporter commented 9 years ago
In my admin module, content controller, and index action, when I type something 
in the field 'title', the url generated is :
http://yujia.fr/admin/content/index/_gridId/index_content_admin/field/titre/_opt
ion/autocomplete?term=U

Best Regards,
Pierre Jolly

Original comment by p...@yujia.fr on 2 Oct 2011 at 10:40

GoogleCodeExporter commented 9 years ago
Hi,

And the correct URL should be: 
http://yujia.fr/fr/admin/content/index/_gridId/index_content_admin/field/titre/_
option/autocomplete?term=U ?

Try setting the route name

$grid->setRoutename('myRoute');

Best Regards,
Bento Vilas Boas

Original comment by bento.vi...@gmail.com on 2 Oct 2011 at 5:26