BootStrap Table 重写API实现 可对列选择性的搜索

来源:互联网 发布:tourex b2b2c源码 编辑:程序博客网 时间:2024/04/30 02:11


下载地址:http://note.youdao.com/yws/public/redirect/share?id=a470bb9ede4466626edfea2946eb3553&type=false


在 bootStrap table .js修改了如下代码片段:



        

        if (this.options.search) {            html = [];            html.push(                '<div class="pull-' + this.options.searchAlign + ' search">',                sprintf('<input class="form-control' +                    sprintf(' input-%s', this.options.iconSize) +                    '" type="text" placeholder="%s">',                    this.options.formatSearch()),                '</div>');            this.$toolbar.append(html.join(''));/** *根据某列进行搜索 */var html_a=[];html_a.push(sprintf('<div  class="search pull-right" style="margin-right:5px;"> ')+sprintf('<select id="sel_column" class="form-control"> '));$.each(this.columns, function (i, column) {if(column.searchable){html_a.push(sprintf('  <option value='+column.field+' >'+column.title+'</option> '));}});html_a.push(sprintf('</select>')+sprintf('</div>'));this.$toolbar.append(html_a.join(''));$('#sel_column').change(function ( event){var text_t=$('.search input').val();that.searchText =text_t;that.scolumnText=$('#sel_column').val();that.options.searchText = text_t;that.options.pageNumber = 1;that.initSearch();that.updatePagination();that.trigger('search', text_t);});            $search = this.$toolbar.find('.search input');            $search.off('keyup drop').on('keyup drop', function (event) {                if (that.options.searchOnEnterKey) {                    if (event.keyCode !== 13) {                        return;                    }                }                clearTimeout(timeoutId); // doesn't matter if it's 0                timeoutId = setTimeout(function () {                    that.onSearch(event);                }, that.options.searchTimeOut);            });            if (isIEBrowser()) {                $search.off('mouseup').on('mouseup', function (event) {                    clearTimeout(timeoutId); // doesn't matter if it's 0                    timeoutId = setTimeout(function () {                        that.onSearch(event);                    }, that.options.searchTimeOut);                });            }        }    };



0 0
原创粉丝点击