Question

I integrated dhtmlx with yii frame work based on the instruction given in their site.( DHTMLX With YII )

here my controller file code,

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();
        }
}

==============================================================================

my view file

<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>

===========================================================================

my modal file

<?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,
        ));
    }
}

when I run the action grid i got the error in the popup window like below,

enter image description here

I don't know what is the issue?. I doubt that may be '$grid = new GridConnector(Events::model(), "PHPYii"); ' this one causes the problem.

How can I resolve this one?. Can anyone help me?.

Was it helpful?

Solution

Yes. I found answer, I need to edit the core extension file dhtmlx/connector/db_phpyii.php like below, (Remove &-reference operator).

Shows – $temp[]=&$obj->getAttributes();
Should read – $temp[]=$obj->getAttributes();

Ref: http://www.dhtmlx.com/blog/?p=1648

OTHER TIPS

Please have a look at the question: Strict Standards: Only variables should be assigned by reference PHP 5.4

Looks like you're using strict standards and passing an object with a reference operator in line 16 of /dhtmlx/connector/db_phpyii.php.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top