jquery.selectable.gridview.js 1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
(function($){

    /**
     * Returns the key values of the currently checked rows.
     * @param id string the ID of the grid view container
     * @param column_id string the ID of the column
     * @return array the key values of the currently checked rows.
     */
    $.fn.yiiGridView.selectable = function (id, filter, callback)
    {
        var grid = $('#'+id) ;
        var selectedItems = [];

        $("tbody", grid).selectable({
            filter: filter,
            distance: 1,
            start: function(e, ui) {
                selectedItems = [];
            },
            selected: function(e, ui){
                selectedItems.push(ui.selected);
            },
            stop: function(e,ui){
                if($.isFunction(callback))
                {
                    callback(selectedItems);
                }
            }
        }).disableSelection();

        grid.on('click', function(){
            $(".ui-selected", grid).removeClass("ui-selected");
        });
    };


})(jQuery);