CGridView Drag and Select Rows

Does CGridView support a drag and select functionality for rows? Like, click one row, drag and select all rows you rollover.

Yes, you can do this. This is a code sample I’ve used to add ‘weight’ to columns for their order of appearance.




    $str_js = "

        var fixHelper = function(e, ui) {

            ui.children().each(function() {

                $(this).width($(this).width());

            });

            return ui;

        };

 

        $('#projects-grid table.items tbody').sortable({

            forcePlaceholderSize: true,

            forceHelperSize: true,

            items: 'tr',

            update : function () {

                serial = $('#projects-grid table.items tbody').sortable('serialize', {key: 'items[]', attribute: 'class'});

                $.ajax({

                    'url': '" . $this->createUrl('/admin/projects/producing') . "',

                    'type': 'post',

                    'data': serial,

                    'success': function(data){

                    },

                    'error': function(request, status, error){

                        alert('We are unable to set the sort order at this time.  Please try again in a few minutes.');

                    }

                });

            },

            helper: fixHelper

        }).disableSelection();

    ";

    Yii::app()->clientScript->registerScript('sortable-project', $str_js);



And for the table, I set the selectable rows to 1, you can of course increase this to be more then your pagination or to your pagination size for no limit.




$this->widget('zii.widgets.grid.CGridView', array(

	'id'=>'projects-grid',

	'dataProvider'=>$model,

   'selectableRows'=>1,

   'rowCssClassExpression'=>'"items[]_{$data->id}"',



Hi, i tried this in grid view. But one of the field in my model is file type. So the change in database not happening. The drag works fine but there is no change in the database. When it can solve?