(on Wednesday, 22 October 2008, 01:58 AM -0700):
> Is it possible to do this?
>
> I want to create a tree from the json of action "ordininav" of controller
> "menu".
>
> this is the action:
>
> public function ordininavAction(){
> $items = array(
> array('id'=>'a', 'label'=>'a ord'),
> array('id'=>'b', 'label'=>'b ord'),
> array('id'=>'c', 'label'=>'c ord'),
> );
>
> $data = new Zend_Dojo_Data('id', $items);
>
> // Encode and send response;
> $this->_helper->autoCompleteDojo($data);
This will break. AutoCompleteDojo was written before the Dojo
integration was even announced, much less implemented, and has its own,
much limited, dojo.data payload implementation. Passing a Zend_Dojo_Data
object to it is simply unsupported.
Your best bet at this time is to instead pass the $data to your view:
$this->view->data = $data;
and in your view do the following:
<?php
$response = Zend_Controller_Front::getInstance()->getResponse();
$response->setHeader('Content-Type', 'application/x-json');
echo $this->data;
This will set the appropriate headers and ensure that you get the full
dojo.data payload that Zend_Dojo_Data is capable of producing.
> }
>
> and this is my view script:
>
> <div dojoType="dojo.data.ItemFileReadStore" jsId="menuOrdini"
> url="</menu/ordininav/"></div>
>
> <div dojoType="dijit.Tree" store="menuOrdini"
> labelAttr="name" label="Menu ORD"
> ></div>
>
> I have added in the dojo()-enable() ->
> ->requireModule('dijit.Tree')
> ->requireModule('dojo.data.ItemFileReadStore').
>
> After these, i can see only the tree without children.
>
> thanks
>
>
>
> --
> View this message in context: http://www.nabble.com/dojo.data-and-controller-action-tp20106622p20106622.html
> Sent from the Zend MVC mailing list archive at Nabble.com.
>
--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/
没有评论:
发表评论