Matthew Weier O'Phinney a écrit :
> Greets, all --
>
> I've committed the complete Zend_Dojo_Data implementation to the
>   
Thank you !!!

What's the handy way to get a proper json ?

I tried a bit, in my controller:

    public function autocompleteAction() {       
        $p= new Catalogue();
        $rows= $p->fetchAll();
     
        $f= new Zend_Dojo_Data();
        $f->setIdentifier('id');
        $f->addItems( $rows );      

        $this->_helper->autoCompleteDojo( $f );
        //echo $f;
    }

I m getting a well formated json file but complicated :
{"identifier":"name",
"items":  [{
    "label": {"id":"1","produit":"pomme"},
    "name": {"id":"1","produit":"pomme"}
},{
    "label": {"id":"2","produit":"orange"},
    "name": {"id":"2","produit":"orange"}
}]}

I'd prefer and "dojo.data.ItemFileReadStore" too, a simpler json like :
{"identifier": "name",
"items": [{
    "label":"pomme",
    "name":"pomme"
},{
    "label":"orange",
    "name":"orange"}
}]}

fyi, this is the schema SQL :
CREATE TABLE `catalogue` (
  `id` int(11) NOT NULL auto_increment,
  `produit` varchar(100) NOT NULL,
  PRIMARY KEY  (`id`) );

FT.

Reply via email to