Yii2 gridview - 仅在单击第一行时显示模态

时间:2017-03-08 09:33:39

标签: gridview yii2 modal-dialog kartik-v yii2-extension

我正在使用kartik \ grid \ GridView和kartik \ grid \ ExpandRowColumn来显示摘要信息。在expandRowColumn上,我有另一个gridview列出详细信息。这部分工作正常。

在expandRowColumn gridview下我使用modal查看列详细信息的数据。单击第一个expandRowColumn上的模式工作正常,但在其他expandRowColumn行上出现错误。

没有错误消息,但没有显示模态 error_image

expandRowColumn上的Gridview

$gridColumns = [
    ['class' => 'yii\grid\SerialColumn'],
    [
    'label'=>Yii::t('app','Borderaux No'),
    'format'=>'raw',
    'value'=>function($data) {
        return $data['bordereaux_number'];
    },
    ],
    [
    'label'=>Yii::t('app','Details'),
            'format'=>'raw',
            'value'=>function($data) {

            if ( $data['status'] != 0 ) {

            //modal - list by borderaux no
                $text = '<i class="fa fa-comments-o fa-fw"></i> View';
                $url = '/inpatient/claim/summaryborderauxdetails?status=' . $data['status'] .
                        "&month=" . $data['month'] . "&year=" . $data['year'] .
                        "&search_type=" . $data['search_type'] . "&reimbursement=" . $data['reimbursement'] .
                        "&client_id=" . $data['client_id'] .'&borderaux_number=' . $data['bordereaux_number'] ;
                $options = [
                            'class' => 'summary-borderaux-link',
                            'data-target' => '#summary-borderaux-modal',
                            'data-toggle'=>'modal',
                            'data-id' => $data['bordereaux_number'],
                            'data-pjax' => '0',
                            ];
                return Html::a( $text, $url , $options  );

            }

            },
            'headerOptions' => ['style'=>'text-align:left;'],     'contentOptions'=>['style'=>'text-align: right;'],
    ],];


Modal::begin(['id' =>'summary-borderaux','size'=>'modal-lg','header' => '<h4 class="modal-title">' . Yii::t('app','Details') .'</h4>']);Modal::end();

Pjax::begin(['id'=>'summary_details','enablePushState'=>FALSE]);
echo GridView::widget(['dataProvider' => $dataProvider,
'id'=>'summary_details_by_borderaux',
'columns' => $gridColumns,]);
Pjax::end(); 


$this->registerJs("$(function() {
$('.summary-borderaux-link').click(function(e) {
e.preventDefault();
 $('#summary-borderaux').modal('show').find('.modal-body')
 .load($(this).attr('href'));
return false;
});
});");

0 个答案:

没有答案