我正在使用Yii 1.1来实现主细节订单-订单细节网格
到目前为止,我得到了他:

-基本上,当我单击详细信息图标(左侧图标)时-它会用ajax加载带有详细信息的详细信息网格(我为此组件使用了一个名为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',
            ),
        ),
    )); ?>


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

'linkAjaxOptions'=>数组(
'type'=>'POST',
'update'=>'#id_view',
),

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

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

最佳答案

我想你想要这个。(将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',
            ),
        ),
    )); ?>

07-24 09:30