Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExpandRowColumn in Modal doesn't work #261

Closed
friek108 opened this issue Apr 3, 2015 · 3 comments
Closed

ExpandRowColumn in Modal doesn't work #261

friek108 opened this issue Apr 3, 2015 · 3 comments

Comments

@friek108
Copy link

friek108 commented Apr 3, 2015

I can't get the expandRowColumn to work for grid inside a modal - it works outside of a modal no problems. Basic code is below to replicate the issue:

<?php
use kartik\grid\GridView;
?><div class="modal" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-local="true">
    <div class="modal-dialog modal-md">
        <div class="modal-content">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
    <h3 class="modal-title" id="myModalLabel">My Modal</h3>
  </div>
  <div class="modal-body">  

    <?php
    echo GridView::widget([
      'id'=>rand(),
      'dataProvider' => $dataProvider,
      'summary'=>'',     
      'formatter'=>[
          'class' => 'yii\i18n\Formatter',
          'nullDisplay'=>'-'
      ],
      'export'=>false,            
      'resizableColumns'=>false,
      'hover'=>true,      
      'striped'=>false,
      'bordered'=>false,      
      'rowOptions' => ['class' => 'pointer-cursor'],
      'tableOptions'=>['class'=>'align-middle'],      
      'columns' => [
        [
          'class'=>'kartik\grid\ExpandRowColumn',
          'enableRowClick'=>true,
          'width'=>'20px',
          'value'=>function ($model, $key, $index, $column) {
              return GridView::ROW_COLLAPSED;
          },
          'detail'=>function ($model, $key, $index, $column) {
              return 'hello world';//Yii::$app->controller->renderPartial('_expand-row-details', ['model'=>$model]);
          },
          'detailAnimationDuration'=>100,
          'expandIcon'=>'<span class="fa fa-angle-right"></span>',
          'collapseIcon'=>'<span class="fa fa-angle-down"></span>',
          //'headerOptions'=>['class'=>'kartik-sheet-style']          
        ],        
        'filter',                  
        'value',
        [          
          'attribute' => 'Clear',
          'hAlign'=>'center',
          'width'=>'80px;',
          'format'=>'raw',
          'value'=>function($model){
            return '<a href="#" data-placement="top" data-tooltip="tooltip" title="" class="grid-delete-btn" data-original-title="Clear Filter"><span class="fa fa-times"></span></a>';
          }
        ]              
      ]
    ]);
    ?>   
  </div>
  <div class="modal-footer">
    <a class="btn btn-default" href="#" data-dismiss="modal">Cancel</a>
    <a href="#" class="btn btn-success">Save</a>    
  </div>
</div>
    </div>
</div> 
<a href="#" class="btn btn-default" data-toggle="modal" data-target="#myModal">Open Modal</a>
@friek108
Copy link
Author

friek108 commented Apr 3, 2015

Looking at kv-grid-expand.js, the var $rows is selecting only visible td elements using this line:

$rows = $grid.find("td:visible .kv-expand-row:not(.kv-state-disabled)"),

Being in a modal, this of course isn't visible when this script is run and so the td elements don't get selected

@kartik-v
Copy link
Owner

kartik-v commented Apr 4, 2015

This will need some thought on the design for such cases... will get back on this when I have some time.

@kartik-v
Copy link
Owner

kartik-v commented Apr 5, 2015

@friek108 you can check now with the fix.

friek108 added a commit to friek108/yii2-grid that referenced this issue Apr 14, 2015
Related to fix kartik-v#261 - the previous fix allowed for initialisation, but
all content in the expanded row would only have a colspan of 1 as
opposed to the amount of columns in the grid.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants