а

DHTMLX integration with yii framework not working?


#1

I integrated dhtmlx with yii frame work based on the instruction given in this site.

here my controller file code,

[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();
		}
}[/code]

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

my view file

[code]<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>[/code]

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

my modal file

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

[/code]

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


I don’t know what is the issue?. I doubt that may be

this one causes the problem.

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

Stackoverflow Question : - http://stackoverflow.com/questions/15700437/dhtmlx-integration-with-yii-framework-not-working


#2

I downloaded package from the following url

http://www.dhtmlx.com/x/download/regular/dhtmlxConnector/connector-yii.zip


#3

Please replace connector files with latest version

github.com/DHTMLX/connector-php … er/samples

Code which you are using is not ready for latest php version ( we will update related package as well )


#4

is am i need to place all the folders " combo,common, dataview, dhtmlz… " all folders and files in to my " dhtmlx -> connector" folder?.

  • I found one thread through surf and i changed one line in ’ db_phpyii.php’ file,

  • FROM $temp[]=&$obj->getAttributes(); TO $temp[]=$obj->getAttributes();

  • now the grid is loaded fine. is that correct way?. or i need to change whole folder like you said?.


#5

Yep, it is the same fix which is included in latest files.