在zend中的Dojo网格实现问题

时间:2012-05-10 14:24:22

标签: sql zend-framework dojo

我真的有大问题无法在zend中实现dojo网格。

这是我的剧本

[View]

<?php $this->headLink()->appendStylesheet($this->baseUrl() . '/scirpts/dojo/dojox/grid/resources/claroGrid.css'); ?>
<?php $this->dojo()->enable(); 
    $this->dojo()->requireModule('dojox.data.QueryReadStore')
                     ->requireModule('dojox.grid.DataGrid');
?>
<div id="view-content">
<?php $this->tabContainer()->captureStart('tabcontainer', array(), array('style' => 'width:100%;height:400px;')) ?>

    <?php $this->contentPane()->captureStart('tab1', array(), array('title' => 'User Manager')); ?>

    <script type="text/javascript" >    
      var structure = [ 
            { field: 'id', name: 'UserID', width: '50px' },
            { field: 'username', name : 'User Name', width: '100px' },
            { field: 'email', name : 'E Mail', width: '200px'}
         ]; 
    </script>
    <span dojoType="dojox.data.QueryReadStore" jsId="users" url="/users/loaduser"></span>
    <div id="grid1" dojoType="dojox.grid.DataGrid" store="users" structure="structure"></div> 

    <?php echo $this->contentPane()->captureEnd('tab1'); ?>
<?php echo $this->tabContainer()->captureEnd('tabcontainer'); ?>
</div>

Controller

 public function loaduserAction()
    {
        // Load current data.
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender();

        $user = new Application_Model_Users();
        $users = $user->getUsers();
        $dojoData = new Zend_Dojo_Data('id', $users, 'id');
        echo $dojoData->toJson();
    }

[Layout]

<?php
 if($this->dojo()->isEnabled()) {

        $this->dojo()-> setDjConfigOption('usePlainJson',true)

                  -> addStylesheetModule("dijit.themes.tundra")
                  -> setLocalPath($this->baseUrl('/scripts/dojo/dojo/dojo.js'));

        echo $this->dojo();

    }

?>   

    <body id="page1" class="tundra">

[Bootstrap]

$view = new Zend_View();
    $view->doctype('XHTML1_STRICT');
    $view->navigation = array();
    $view->subnavigation = array();


    $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); 
    $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer(); 
    $viewRenderer->setView($view);
    Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);

它没有显示任何内容,我没有检查javascript错误,这是我在网上找到的一个很好的教程,但似乎没有任何工作。我真的很沮丧。我需要你的帮助!!!

1 个答案:

答案 0 :(得分:0)

如果显示dojox.grid.DataGrid中的列名,则需要检查检索到的json。否则检查dojox.grid.DataGrid的CSS。通常,您需要明确指定dojox.grid.DataGrid的宽度和高度,如下所示:

style="width: 800px; height: 500px"