0

我有一个非常大的问题,无法在 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 错误,这是我在网上找到的很好的教程之一,但似乎没有任何效果。我真的很沮丧。我需要你的帮助!!!

4

1 回答 1

0

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

style="width: 800px; height: 500px"
于 2012-05-25T20:32:42.393 回答