Yii Framework Forum: get selected column in gridview - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

get selected column in gridview Rate Topic: -----

#1 User is offline   ikramadjissa 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 22-June 15

Posted 03 August 2015 - 01:52 PM

hello , I have a problem in getting the selected row using kartik grid view. Here is my code :

the view:

<?= GridView::widget([
    'dataProvider'=> $dataProvider,
    'filterModel' => $searchInstance,
		'containerOptions' => ['class' => 'instance-pjax-container'],
		
		
		'export' => false,
    'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'codebien',
		    'designationbien',
            'codesousfamille',
            'numfacture',
            'dt',
		    ['class' => 'yii\grid\CheckboxColumn'],

            ['class' => 'yii\grid\ActionColumn'],
        ],
    
    
]);?>


  <?= Html::SubmitButton( 'Affecter', [ 'class' => 'btn btn-success' , 'id' =>'x']) ?>    


  

  
  
  
  <?php
$script = <<< JS
$(function () {
		 $('#x').click(function(){
		
		 	$.post(
    "listeaffecter", 
    {
        pk : $('#instance-pjax-container').yiiGridView('getSelectedRows')
    },
    function () {
        $.pjax.reload({container:'#instance-pjax-container'});
    }
);
		
		 });
		
  });

JS;
$this->registerJs($script);
?>
  



the controller :

public function actionListeaffecter(){
    	 			
    	 			$searchInstance = new InstanceSearch();
    	 			$dataProvider = $searchInstance->search(Yii::$app->request->queryParams);
    	 			$pk = Yii::$app->request->post('pk'); // Array or selected records primary keys
    	 			if ($pk) {
    	 				print ("select=$pk");
    	 			}    	
    	 			    	 				
    	 			     return $this->render('vueListeAaffecter', [
    	 					'searchInstance' => $searchInstance,
    	 					'dataProvider' => $dataProvider,
    	 					]);
    	 			
    	 		}


Any help plz
0

#2 User is offline   ikramadjissa 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 22-June 15

Posted 03 August 2015 - 02:53 PM

It's not necessary for me to use pjax. I put it because I found it in a forum. My aim is to get the selected rows
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users