Sha256: dd31aa744cd8db492455b22040e2624d4a81a3a16734c75bc25174b36c966ccc

Contents?: true

Size: 1.93 KB

Versions: 9

Compression:

Stored size: 1.93 KB

Contents

/**
 * @author zhixin wen <wenzhixin2010@gmail.com>
 * extensions: https://github.com/lukaskral/bootstrap-table-filter
 */

!function($) {

    'use strict';

    $.extend($.fn.bootstrapTable.defaults, {
        showFilter: false
    });

    var BootstrapTable = $.fn.bootstrapTable.Constructor,
        _init = BootstrapTable.prototype.init,
        _initSearch = BootstrapTable.prototype.initSearch;

    BootstrapTable.prototype.init = function () {
        _init.apply(this, Array.prototype.slice.apply(arguments));

        var that = this;
        this.$el.on('load-success.bs.table', function () {
            if (that.options.showFilter) {
                $(that.options.toolbar).bootstrapTableFilter({
                    connectTo: that.$el
                });
            }
        });
    };

    BootstrapTable.prototype.initSearch = function () {
        _initSearch.apply(this, Array.prototype.slice.apply(arguments));

        if (this.options.sidePagination !== 'server') {
            if (typeof this.searchCallback === 'function') {
                this.data = $.grep(this.options.data, this.searchCallback);
            }
        }
    };

    BootstrapTable.prototype.getData = function () {
        return (this.searchText || this.searchCallback) ? this.data : this.options.data;
    };

    BootstrapTable.prototype.getColumns = function () {
        return this.columns;
    };

    BootstrapTable.prototype.registerSearchCallback = function (callback) {
        this.searchCallback = callback;
    };

    BootstrapTable.prototype.updateSearch = function () {
        this.options.pageNumber = 1;
        this.initSearch();
        this.updatePagination();
    };

    BootstrapTable.prototype.getServerUrl = function () {
        return (this.options.sidePagination === 'server') ? this.options.url : false;
    };

    $.fn.bootstrapTable.methods.push('getColumns',
        'registerSearchCallback', 'updateSearch',
        'getServerUrl');

}(jQuery);

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
bootstrap-table-rails-1.12.2 vendor/assets/javascripts/bootstrap-table/extensions/filter/bootstrap-table-filter.js
bootstrap-table-rails-1.12.1 vendor/assets/javascripts/extensions/bootstrap-table-filter.js
bootstrap-table-rails-1.11.1.1 vendor/assets/javascripts/extensions/bootstrap-table-filter.js
bootstrap-table-rails-1.11.0 vendor/assets/javascripts/extensions/bootstrap-table-filter.js
bootstrap-table-rails-1.10.1 vendor/assets/javascripts/extensions/bootstrap-table-filter.js
bootstrap-table-rails-1.10.0 vendor/assets/javascripts/extensions/bootstrap-table-filter.js
bootstrap-table-rails-1.9.1 vendor/assets/javascripts/extensions/bootstrap-table-filter.js
bootstrap-table-rails-1.9.0 vendor/assets/javascripts/extensions/bootstrap-table-filter.js
bootstrap-table-rails-1.8.2.1 vendor/assets/javascripts/extensions/bootstrap-table-filter.js