kartik-v / yii2-tabs-x

Extended bootstrap tabbed navigation widget for Yii 2.0 with various alignment and styling options.
Other
30 stars 17 forks source link

tabs-x and gridview #24

Closed chrisschd closed 5 years ago

chrisschd commented 9 years ago

Hello,

I’ve a problem with tabx and gridview, follow scenario:

Tabx:

In view file view/user/details.php and controller UserController.php

  1. Item “home” is rendered by “content” with render function (_home.php), all variables will be supported from UserController.php/actionDetails which render the details.php.
  2. Item “Customer” use the “linkOptions” with 'linkOptions'=>['data-url'=>\yii\helpers\Url::to(['=/app/user/customerlist, 'id'=>$model->ID])] where $model comes from the UserController.php/actionDetails.
  3. Item “Products” use also the linkOptions with 'linkOptions'=>['data-url'=>\yii\helpers\Url::to(['=/app/user/productlist, 'id'=>$model->ID])] where $model comes from the UserController.php/actionDetails.

Item “Customer” and “Products” has both the GridView in use. The first page of the GridView of the “Customer” and “Product” items is ok but if I click on the second page button or enter some filter/search text it fails. The view view/user/details.php will exit, the browser load (on click of the GridView “Customer”) the text values from the UserController.php/actionCustomerlist which is a Json:encoded output (echo Json::encode($html);)

Some Code Fragments:

The ActionCustomerlist

public function actionCustomerlist ($id)

    {

       $searchModel = new UsercustomerSearch();

       $dataProvider = $searchModel->search(Yii::$app->request->queryParams);

       $dataProvider->query->andWhere(['user_ID' => $id]);

       $html = $this->renderPartial('_usercustomer', [

                    'searchModel' => $searchModel,

                    'dataProvider' => $dataProvider,

                    'user_ID' => $id,

       ]);

       return Json::encode($html);

    }

The _usercustomer.php

Pjax::begin(['id' => 'usercustomer-site']);

GridView::widget([ …
]);

Pjax::end();

The _userproduct.php

Pjax::begin(['id' => 'userproduct-site']);

GridView::widget([ …
]);

Pjax::end();

The grid view has also an ID.

Where is my mistake? Thanks for help.

vovkee commented 9 years ago

Hello, same here( Have you found any solutions?

m00nh3ck commented 8 years ago

I am not sure if this the same thing I had a problem.

I am using grid tab-x with multiple grid view and resolve the issue with filter by using Pjax settings with kartik GridView

use kartik\grid\GridView;

$customerContactsOverview= GridView::widget([ 'dataProvider' => $dataContactsProvider,
'filterModel'=>$searchContactsModel,
'autoXlFormat'=>true, 'pjax'=>true,
'pjaxSettings'=>[ 'neverTimeout'=>true, 'refreshGrid' => true, ], 'export'=>[ 'fontAwesome'=>true, 'showConfirmAlert'=>false, 'target'=>GridView::TARGET_BLANK ],

paskuale75 commented 7 years ago

For me don't work :( any solution ?

m00nh3ck commented 7 years ago

I am using the following and it works.

Have you updated to latest version?

Are you using separate data and filter providers?

'dataProvider' => $dataContactsProvider,
'filterModel'=>$searchContactsModel,

I am using kartik this

use kartik\grid\GridView;
use kartik\tabs\TabsX;

echo TabsX::widget([
    'position' => TabsX::POS_ABOVE,
    'align' => TabsX::ALIGN_LEFT,
    'encodeLabels'=>false,
    'enableStickyTabs' => true,
    'stickyTabsOptions' => [
      // 'selectorAttribute' => "data-target",
        //'backToTop' => true,
    ],

    'items' => [
        [
            'label'=>'<i class="glyphicon glyphicon-home"></i> Details',
            'content' => $customerOverview,

        ],
        [
            'label'=>'<i class="glyphicon glyphicon-list-alt"></i> Tickets',
            'content' => $ticketsOverview,                       
        ],
        [
            'label'=>'<i class="glyphicon glyphicon-list-alt"></i> Projects',
            'content' => $projectsOverview,                       
        ],
        [
            'label'=>'<i class="glyphicon glyphicon-list-alt"></i> Contacts',
            'content' => $customerContactsOverview,           

        ],   
        [
            'label'=>'<i class="glyphicon glyphicon-list-alt"></i> Users',
            'content' => $assignedUsers,           

        ],       
    ],
]);  

 $customerContactsOverview= GridView::widget([
        'dataProvider' => $dataContactsProvider,    
        'filterModel'=>$searchContactsModel,  
        'autoXlFormat'=>true,
        'pjax'=>true,        
        'pjaxSettings'=>[
            'neverTimeout'=>true,
            'refreshGrid' => true,
        ],
        'export'=>[
            'fontAwesome'=>true,
            'showConfirmAlert'=>false,
            'target'=>GridView::TARGET_BLANK
        ], 
        'columns' => [                    
            [
            'class' => '\kartik\grid\SerialColumn',
            ],
            [                
                'attribute' => 'contact_id',                         
                'format' => 'raw',
                'value'=>function ($model, $key, $index, $widget) {                 
                  return Html::a($model->contact_id, ['customers-contacts/view','id' => $model->contact_id], [
                'title'=>'View Contact detail',                
            ]);
            }, 
            ],                    
            'contact_name',            
            'contact_email',            
            'contact_tel',
             [
                'attribute' => 'contact_type',        
                'value' => function ($model){
                $types=null;  
                 if(isset($model->contact_type) and !empty($model->contact_type)){
                    $model['contact_type'] = str_split($model->contact_type,1);   
                    foreach($model->contact_type as $type){
                        if(isset(Yii::$app->params['contacttypes'][$type])){
                            $types = $types.Yii::$app->params['contacttypes'][$type]." ";                        
                        }                    
                    }
                    return $types;
                    }
                },
                'filterType'=>GridView::FILTER_SELECT2,
                    'filterWidgetOptions'=>[                         
                        'theme' => 'krajee',
                        'options' => ['placeholder' => 'Type ...'],
                        'data' => Yii::$app->params['contacttypes'],
                        'pluginOptions'=>[
                            'allowClear' => true,                             
                        ],
                ],           
            ], 

        ],//columns
         'panel' => [
        'heading'=>'<h3 class="panel-title"><i class="glyphicon glyphicon-list"></i> Customer Contacts</h3>',
        'type'=>'info',        

    ],
     'toolbar' =>  [
            [
            'content'=>
                Html::a('<i class="glyphicon glyphicon-plus"></i>',['customers-contacts/create'], [
                    'type'=>'button', 
                    'title'=>'Create New Ticket',
                    'class'=>'btn btn-success',
                    'action' => 'create',
                ]),
            ],    
            '{export}',
            '{toggleData}'
    ],
        'responsive'=>true,
        'hover'=>true,   
    ]);
stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.