dimanche 13 novembre 2016

Checking Multiple CheckBoxes by Clicking on One in Yii

Firstly I wanna display data from Table along with CheckBoxColumn . And At the header for CheckBoxColumn , I have a Check Box .. So how to check all the Checkboxes from all rows by selecting the only Header checkbox in Yii and viseversa..?

Here is MyCode in view

'columns'=>array(
                    array(
                            'header'=>'html',
                            'id'=>'autoId',
                            'class'=>'CCheckBoxColumn',
                           // 'checked'=>'false',
                            'selectableRows' => '50',
                            //'headerTemplate'=>'<label>Select All{item}<span></span></label>',
                            'value'=>'$data->Id',
                            'htmlOptions'=>array("width"=>"40px;","align"=>"center"),
                            //'headerHtmlOptions' => array('style' => 'display:none'),
                            //'htmlOptions' => array('style' => 'display:none'),

                    ),
)

and

jQuery(function($) {
                jQuery(document).on('click','#autoId_all',function() {
                var checked=this.checked;
                    jQuery("input[name='autoId\[\]']:enabled").each(function() {this.checked=checked;});
                });

                     jQuery(document).on('click', "input[name='autoId\[\]']", function() {
                    jQuery('#autoId_all').prop('checked', jQuery("input[name='autoId\[\]']").length==jQuery("input[name='autoId\[\]']:checked").length);
                     });
});

please help




Aucun commentaire:

Enregistrer un commentaire