Yii:CGridView上AJAX操作的动态更新ID

时间:2012-05-09 11:48:20

标签: jquery ajax grid widget yii

我正在使用Yii 1.1来实现主详细订单订单详细信息网格 到目前为止我得到了他的: enter image description here - 当我点击详细信息图标(左图标)时基本上 - 它用ajax加载带有oder详细信息的详细网格(我使用了一个名为EAjaxLinkColumn的组件 - 默认情况下链接列不支持ajax)

这是我的代码:

<?php     $this->widget('zii.widgets.grid.CGridView', array(
        'id'=>'main-orders-grid',
        'dataProvider'=>$model->search(),
        'filter'=>$model,
        'columns'=>array(

    array (
    'class'=>'EAjaxLinkColumn',
    'header'=>'Details',
    'url'=>Yii::app()->createUrl('mainOrdersDetails/detailview'),
    'imageUrl'=>Yii::app()->request->baseUrl.'/images/zoom_in.png',

          //linkAjaxOptions and linkAjaxOptionsExpression are merged together, so only put the ones
          //that actually need to be evaluated in the latter
          'linkAjaxOptions' => array(
             'type' => 'POST',
             /*'dataType' => 'json',       */
             'update'=>'#id_view',
          ),
          //In this expression, the variable $row the row number (zero-based); 
          //$data the data model for the row; and $this the column object.
          'linkAjaxOptionsExpression' => array(
             'data' => array(
               'id' => '$data->id' //note that $data->id is an expression so must be quoted
             ),
          ),

    ),    

            'id',   
            'storageF.name',
            'date_added',
            'order_number',
            'expected_ship_date',
            'shipped_date',
            'shipping_costs',
            'personF.user',
            'date_to_pay',
            'paid_integraly',
            'paid_partialy',        
            array(
                'class'=>'CButtonColumn',
            ),
        ),
    )); ?>

我想要的是在每行下方加载它的细节。好吧,我不知道该怎么做..因为CGridView小部件对于像Yii这样的初学者来说非常奇怪 现在它总是加载到同一个div中。注意

'linkAjaxOptions'=&gt;阵列(      'type'=&gt; 'POST',      '更新'=&GT; '#id_view',   ),

首先,更新选项是静态的..我想按ID#id_view_1#id_view_2使用 然后以某种方式在每个主行下面插入那些空行

可能我可以直接使用Jquery而不是复杂的CGrid选项?

1 个答案:

答案 0 :(得分:1)

我想你想要这个。(将update属性从linkAjaxOptions移动到linkAjaxOptions,就像在linkAjaxOptions中一样,我们可以使用特殊变量$ data和$ row

<?php     $this->widget('zii.widgets.grid.CGridView', array(
        'id'=>'main-orders-grid',
        'dataProvider'=>$model->search(),
        'filter'=>$model,
        'columns'=>array(

    array (
    'class'=>'EAjaxLinkColumn',
    'header'=>'Details',
    'url'=>Yii::app()->createUrl('mainOrdersDetails/detailview'),
    'imageUrl'=>Yii::app()->request->baseUrl.'/images/zoom_in.png',

          //linkAjaxOptions and linkAjaxOptionsExpression are merged together, so only put the ones
          //that actually need to be evaluated in the latter
          'linkAjaxOptions' => array(
             'type' => 'POST',
             /*'dataType' => 'json',       */
          ),
          //In this expression, the variable $row the row number (zero-based); 
          //$data the data model for the row; and $this the column object.
          'linkAjaxOptionsExpression' => array(
             'data' => array(
               'id' => '$data->id' //note that $data->id is an expression so must be quoted
             ),

             'update'=>'\'#id_view_\'.$data->id',//or you can use '\'#id_view_\'.$row'; according to your needs
          ),

    ),    

            'id',   
            'storageF.name',
            'date_added',
            'order_number',
            'expected_ship_date',
            'shipped_date',
            'shipping_costs',
            'personF.user',
            'date_to_pay',
            'paid_integraly',
            'paid_partialy',        
            array(
                'class'=>'CButtonColumn',
            ),
        ),
    )); ?>
相关问题