我对此很陌生。我想在网格结构下制作网格,所以我使用了Yii-booster Extensions,但它没有工作
我的代码:
Extensions:
protected/extensions/booster
我的模块
protected/modules/delivery/controllers
DefaultController.php
public function actionIndex()
{
$dataProvider = new models\db\DNote();
$columns = $dataProvider->getColumnsDelivery();
$this->render('index',array('dataProvider'=>$dataProvider,'columns'=>$columns));
}
public function actionRelational()
{
Yii::app()->clientScript->scriptMap['jquery.js'] = false;
Yii::app()->clientScript->scriptMap['jquery.min.js'] = false;
$dataProvider = new models\db\DNoteLine();
$this->renderPartial('_relational', array(
'gridDataProvider' => $dataProvider
), false, true);
}
的index.php
<?php
$this->widget('ext.booster.widgets.TbExtendedGridView', array(
//'filter'=>$dataProvider,
'type'=>'striped bordered',
'id'=>'DeliveryNote-grid',
'dataProvider' => $dataProvider->search(),
'template' => "{items}",
'columns' => array_merge(array(
array(
'class'=>'application.extensions.booster.widgets.TbRelationalColumn',
'name' => 'Edit',
'url' => $this->createUrl('default/relational'),
'value'=> '"test-subgrid"',
'afterAjaxUpdate' => 'js:function(tr,rowid,data){
bootbox.alert("I have afterAjax events too!
This will only happen once for row with id: "+rowid);
}'
)
),$columns),
));
?>
_relational.php
<?php $this->widget('application.extensions.booster.widgets.TbExtendedGridView', array(
//'filter'=>$DataProvider,
'type'=>'striped bordered',
'id'=>'Deliverysample-grid',
'dataProvider' => $dataProvider->search(),
'template' => "{items}",
'columns' => $columns,
));
?>
TbRelationalcolumn.php
public function registerClientScript() {
$booster= Booster::getBooster();
$booster->registerAssetCss('bootstrap-relational.css');
/** @var $cs CClientScript */
$cs = Yii::app()->getClientScript();
if ($this->afterAjaxUpdate !== null) {
if ((!$this->afterAjaxUpdate instanceof CJavaScriptExpression)
&& (strpos($this->afterAjaxUpdate,'js:') !== 0)
) {
$this->afterAjaxUpdate = new CJavaScriptExpression($this->afterAjaxUpdate);
}
} else {
$this->afterAjaxUpdate = 'js:$.noop';
}
$this->ajaxErrorMessage = CHtml::encode($this->ajaxErrorMessage);
$afterAjaxUpdate = CJavaScript::encode($this->afterAjaxUpdate);
$span = count($this->grid->columns);
//$loadingPic = CHtml::image($booster->getAssetsUrl() . '/img/loading.gif');
$loadingPic = CHtml::image( '../img/loading.gif');
$cache = $this->cacheData ? 'true' : 'false';
$data = !empty($this->submitData) && is_array($this->submitData) ? $this->submitData : 'js:{}';
$data = CJavascript::encode($data);
list($parentId) = explode('_',$this->id);
//die ($parentId + $this->cssClass);
$js = <<<EOD
$(document).on('click','#{$parentId} .{$this->cssClass}', function(){
alert ($parentId + $this->cssClass);
var span = $span;
var that = $(this);
var status = that.data('status');
var rowid = that.data('rowid');
var tr = $('#relatedinfo'+rowid);
var parent = that.parents('tr').eq(0);
var afterAjaxUpdate = {$afterAjaxUpdate};
if (status && status=='on'){return}
that.data('status','on');
if (tr.length && !tr.is(':visible') && {$cache})
{
tr.slideDown();
that.data('status','off');
return;
}else if (tr.length && tr.is(':visible'))
{
tr.slideUp();
that.data('status','off');
return;
}
if (tr.length)
{
tr.find('td').html('{$loadingPic}');
if (!tr.is(':visible')){
tr.slideDown();
}
}
else
{
var td = $('<td/>').html('{$loadingPic}').attr({'colspan':$span});
tr = $('<tr/>').prop({'id':'relatedinfo'+rowid}).append(td);
/* we need to maintain zebra styles :) */
var fake = $('<tr class="hide"/>').append($('<td/>').attr({'colspan':$span}));
parent.after(tr);
tr.after(fake);
}
var data = $.extend({$data}, {id:rowid});
$.ajax({
url: '{$this->url}',
data: data,
success: function(data){
tr.find('td').html(data);
that.data('status','off');
if ($.isFunction(afterAjaxUpdate))
{
afterAjaxUpdate(tr,rowid,data);
}
},
error: function()
{
tr.find('td').html('{$this->ajaxErrorMessage}');
that.data('status','off');
}
});
});
EOD;
$cs->registerScript(__CLASS__ . '#' . $this->id, $js);
}
我得到标题网格。当我点击编辑(测试子网格)时,即使我没有收到警报消息也没有任何反应。 请任何人帮忙解决这个问题