DHTMLX与yii框架的集成不起作用?

DHTMLX与yii框架的集成不起作用?,yii,dhtmlx,Yii,Dhtmlx,我根据其网站中给出的说明,将dhtmlx与yii框架集成。() 这里是我的控制器文件代码 include_once(YII_BASE_PATH . "/dhtmlx/connector/grid_connector.php"); include_once(YII_BASE_PATH . "/dhtmlx/connector/scheduler_connector.php"); include_once(YII_BASE_PATH . "/dh

我根据其网站中给出的说明,将dhtmlx与yii框架集成。()

这里是我的控制器文件代码

include_once(YII_BASE_PATH . "/dhtmlx/connector/grid_connector.php");
 include_once(YII_BASE_PATH . "/dhtmlx/connector/scheduler_connector.php");
 include_once(YII_BASE_PATH . "/dhtmlx/connector/db_phpyii.php");
 
class EventsController extends Controller
{
          public function accessRules()
    {
        return array(
            array('allow',  // allow all users to perform 'index' and 'view' actions
                'actions'=>array('index','view','grid','scheduler'),
                'users'=>array('*'),
            ),
            array('allow', // allow authenticated user to perform 'create' and 'update' actions
                'actions'=>array('create','update'),
                'users'=>array('@'),
            ),
            array('allow', // allow admin user to perform 'admin' and 'delete' actions
                'actions'=>array('admin','delete'),
                'users'=>array('admin'),
            ),
            array('deny',  // deny all users
                'users'=>array('*'),
            ),
        );
    }


           public function actionGrid()
        {            
            // $this->render('grid'); //loads the 'grid' view that we will create later
               $model = new Events();   
               
               $this->render('grid',array(
                    'model'=>$model,
                ));
        }
        
        public function actionGrid_data()
        {
                //$model = new Events;
            $grid = new GridConnector(Events::model(), "PHPYii");
            $grid->configure("-","event_id", "start_date, end_date, event_name");
            $grid->render();
        }
}
==============================================================================

我的视图文件

<script src="<?php echo AT::getAdminBaseUrl()?>/dhtmlx/grid/dhtmlxcommon.js"    type="text/javascript" charset="utf-8"></script>
<script src="<?php echo AT::getAdminBaseUrl()?>/dhtmlx/grid/dhtmlxgrid.js"  type="text/javascript" charset="utf-8"></script>
<script src="<?php echo AT::getAdminBaseUrl()?>/dhtmlx/grid/dhtmlxgridcell.js"  type="text/javascript" charset="utf-8"></script>

<script src="<?php echo AT::getAdminBaseUrl()?>/dhtmlx/dhtmlxdataprocessor.js"  type="text/javascript" charset="utf-8"></script>
<script src="<?php echo AT::getAdminBaseUrl()?>/dhtmlx/connector/connector.js"  type="text/javascript" charset="utf-8"></script>

<link rel="stylesheet" href="<?php echo AT::getAdminBaseUrl()?>/dhtmlx/grid/dhtmlxgrid.css" type="text/css" media="screen" title="no title" charset="utf-8">
<link rel="stylesheet" href="<?php echo AT::getAdminBaseUrl()?>/dhtmlx/grid/skins/dhtmlxgrid_dhx_skyblue.css" type="text/css" media="screen" title="no title" charset="utf-8">  

        
<div id="grid_here" style="width:600px; height:400px;"> </div>
 <?php 
                                    // $this->widget('zii.widgets.CListView', array(
                                        // 'dataProvider'=>$dataProvider,
                                        // 'itemView'=>'_view',
                                    // )); 
                                ?>
        <script type="text/javascript">
          mygrid = new dhtmlXGridObject('grid_here'); 
          mygrid.setHeader("Start date,End date,Text");
          mygrid.init();                           
          mygrid.loadXML("./grid_data"); //refers to the 'Grid_data' action we created in the previous step
 
          var dp = new dataProcessor("./grid_data"); //refers to the 'Grid_data' action as well
          dp.init(mygrid);
 
        </script>

请看一看问题:


看起来您使用的是严格的标准,并在
/dhtmlx/connector/db_phpyii.php

的第16行传递了一个带有引用运算符的对象。我找到了答案,我需要编辑核心扩展文件
dhtmlx/connector/db_phpyii.php
如下所示,(删除和引用运算符)

参考:

<?php

/**
 * This is the model class for table "vendor".
 *
 * The followings are the available columns in table 'vendor':
 * @property integer $id
 * @property string $vendor_name
 * @property string $vendor_description
 * @property string $status
 */
class Events extends CActiveRecord
{
    /**
     * Returns the static model of the specified AR class.
     * @param string $className active record class name.
     * @return Vendor the static model class
     */
    public static function model($className=__CLASS__)
    {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName()
    {
        return 'events';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules()
    {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('event_name', 'length', 'max'=>255),
                      // The following rule is used by search().
            // Please remove those attributes that should not be searched.
                    array('start_date,end_date,event_name', 'safe', 'on'=>'search'),
        );
    }

    /**
     * @return array relational rules.
     */
    public function relations()
    {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels()
    {
        return array(
            'event_id' => 'Event Id',
                    'start_date' => 'Start Date',
                    'end_date' => 'End Date',
                    'event_name' => 'Event Name',
            
        );
    }

    /**
     * Retrieves a list of models based on the current search/filter conditions.
     * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
     */
    public function search()
    {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.

        $criteria=new CDbCriteria;

        $criteria->compare('event_id',$this->event_id);
        $criteria->compare('start_date',$this->start_date,true);
        $criteria->compare('end_date',$this->end_date,true);
        $criteria->compare('event_name',$this->event_name,true);
              

        return new CActiveDataProvider($this, array(
            'criteria'=>$criteria,
        ));
    }
}
Shows – $temp[]=&$obj->getAttributes();
Should read – $temp[]=$obj->getAttributes();