help me pliz checkbox selected is not working


help me pliz, i’m a new guy in Yii framework, i’m tring to make multiple selection checkbox in GridView and i’m using yii booster too.

here is my code.

controller code :

public function actionIndex()



	$sqlquery="select id,nama,panggilan,alamat1,kota,jabatan,status from karyawan";


	$jadiarray = new CArrayDataProvider($datakaryawan,array('pagination'=>array('pageSize'=>5)));


	$formkaryawan=new Karyawan;		




private function bentukkolom()


	$isigrid= array(

		array('class'=>'CCheckBoxColumn','selectableRows' => 2,'checkBoxHtmlOptions' => array(        'name' => 'userids[]'),),

    	array('name'=>'id', 'header'=>'No.','htmlOptions'=>array('style'=>'width: 40px')),

    	array('name'=>'nama', 'header'=>'Nama Lengkap'),

    	array('name'=>'panggilan', 'header'=>'Panggilan'),

    	array('name'=>'alamat1', 'header'=>'Alamat 1'),

    	array('name'=>'kota', 'header'=>'Kota'),

    	array('name'=>'jabatan', 'header'=>'Jabatan'),

    	array('name'=>'status', 'header'=>'Status'),



    		'htmlOptions' => array('nowrap'=>'nowrap'),




    		'deleteButtonUrl'=>'Yii::app()->createUrl("karyawan/hapus", array("id"=>$data->id))',



    return $isigrid;



public function actionHapusglobal()



        //if(isset($_POST['ids'])) {

        		echo "get in herey";

                //print_r( $_POST['']);

                foreach($_POST['theIds'] as $val) {

                        echo $val . '<br/>';


            //  }




and my view


/* @var $this SiteController */



<div class="row">

    <div class="col-lg-12" style="padding-top:20px ">

        <h2 style="padding-left:200px ">MASTER DATA KARYAWAN DAN USER</h2>

        <?php $box = $this->beginWidget('booster.widgets.TbPanel',


                'title' => 'DAFTAR KARYAWAN',

                'headerIcon' => 'user',

                'padContent' => false,

                'htmlOptions' => array('class' => 'bootstrap-widget-table'),

                'headerButtons' =>



                        	'class' => 'booster.widgets.TbButtonGroup',

                        	'context' => 'primary',

                       		 //'toggle' => 'radio',

                       		 'buttons' => 


                                	 array('label' => 'Left', 'url' => '#'),

                               		 array('label' => 'Hapus Global', 'url' => '#',                   

													//'onclick' => 'js:hapusbulk()',




                               		 /*array('label' => 'Tambah', 'url' => '#', 

                                		'htmlOptions' => array(

													'data-toggle' => 'modal',

													'data-target' => '#formModal',),

										//'onclick' => "js: submitForm()",









       <div id="for-link">








   				 'type' => 'striped hover',

   				 'dataProvider' => $datakaryawan,

   				 'template' => "{items}{pager}",

   				 'columns' => $isigrid,

   				 'enablePagination' => true, 






<?php $this->endWidget(); ?>



<?php $this->renderPartial('_form',array('model'=>$formkaryawan));?>            



      <div id="output">asd</div>  







        var checked=$("#gridcust").yiiGridView("getChecked","gridcust_c0"); // _c0 means the checkboxes are located in the first column, change if you put the checkboxes somewhere else

        var count=checked.length;


                alert("No items selected");


        if(count>0 && confirm("Do you want to delete these "+count+" item(s)"))










result of checked grid alwas return no items selected, even i’ve checked all grid. i’ ve tried these links

link 1

and link 2

but the result alwasys return zero, whats wrong with my code, help me plis?

i’ve finally solved my problem,

i removed name[] beome this

array('class'=>'CCheckBoxColumn','selectableRows' => 2,'checkBoxHtmlOptions' => array(),),

Hi Thommy

If you want the checkboxes to keep their values after gridview pagination, check out this post:

Retain Checkbox Value

If your gridview is part of a form and you want the checkboxes to keep their values after form submission, check the "Also make this work on normal form submit" answer on the same post.

okay thx Gerhard i’ll try it.