关于在TbRelationalColumn视图中更新CGridViews

时间:2014-08-18 05:13:37

标签: php yii

在我的TbRelationalColumn视图页面中,我有一个javascript,它会在单击操作按钮时刷新视图中的子网格。但是,如果用户打开多个子网格,则网格更新仅适用于第一个打开的子网格。

我认为这是因为网格ID对于子网格而言并不是唯一的。有人可以帮忙吗?

$this->widget('bootstrap.widgets.TbGridView', array
(
'id'=>'main-grid',
     ...
'columns'=>array
(
    array('header'=>'Sl No','value'=>'$this->grid->dataProvider->pagination->currentPage * $this->grid->dataProvider->pagination->pageSize + ($row+1)', 'headerHtmlOptions'=>array('style' =>'text-align: center;'), 'htmlOptions'=> array('style'=>'text-align: center;')),
    array
    (
            'name'=>'indent_no', 'header'=>'Indent No',
            'class'=>'bootstrap.widgets.TbRelationalColumn',
            'url' => $this->createUrl('indent/view'),
            'afterAjaxUpdate' => 'js:function(tr,rowid,data){}'
    ),

缩进/视图内容:

<?php $this->widget('bootstrap.widgets.TbGridView', array
(
    'id'=>'sub-grid',
    'dataProvider'=>Indent::model()->searchIndentedItems($id),
    "ajaxUpdate"=>true,
    'template'=>"{items}",
    'filter'=>null,
    'columns'=>array
    (
        array
        (
            'header' => 'Actions',
            'class'=>'CButtonColumn',
            'template'=>'{block} ',
            'buttons' => array
            (
                'block'=>array
                (
                        'url' =>'Yii::app()->createUrl("indent/block", array("id"=>$data->id))',
                        'imageUrl'=>Yii::app()->request->baseUrl.'/images/block.jpg',
                        'options'=>array(''),
                        'click'=>"function(){ 
                                      $.ajax({'type':'post', 'url':$(this).attr('href'),
                                      'success':function(data){ if ( data.substring(1,8) != 'success') { alert(data); } else { $.fn.yiiGridView.update('sub-grid'); } exit; },
                                      'error':function(xhr, status, error){ alert(xhr.responseText);exit; }}); return false;}",
                        'visible'=>  '($data->indented_item_status == "Active")  && User::model()->checkAccess("Block Indented Item")?"1":"0";',
                ),
            ),
        )   
    )
)
); ?>

0 个答案:

没有答案
相关问题