gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 12:49:01 25 4
gpt4 key购买 nike

我根据网站上给出的说明将 dhtmlx 与 yii 框架集成。( DHTMLX With YII )

这里是我的 Controller 文件代码,

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

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

我的 View 文件

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

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

我的模态文件

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

当我运行 Action 网格时,我在如下弹出窗口中收到错误消息,

enter image description here

不知道是什么问题?我怀疑这可能是 '$grid = new GridConnector(Events::model(), "PHPYii"); ' 这是导致问题的原因。

我该如何解决这个问题?。谁能帮帮我?

最佳答案

是的。我找到了答案,我需要编辑核心扩展文件 dhtmlx/connector/db_phpyii.php如下所示,(删除 &-reference 运算符)。

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

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

关于yii - DHTMLX 与 yii 框架的集成不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15700437/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com