首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >引导表-搜索工具的更改属性

引导表-搜索工具的更改属性
EN

Stack Overflow用户
提问于 2016-10-04 07:57:50
回答 1查看 6.1K关注 0票数 0

我想改变边框的颜色,并在引导表框架中为搜索工具添加右侧的图标。

另外,我想对齐表顶部的其他按钮。

我的代码是:

代码语言:javascript
复制
/* SEARCH TOOL */

.search{
    width: 25%;
}

.fixed-table-toolbar .bs-bars,
.fixed-table-toolbar .search,
.fixed-table-toolbar .columns {
    position: relative;
    margin-top: 10px;
    margin-bottom: 10px;
    line-height: 34px;
}


<table class='table-bordered' id='tableprod'
                    data-toggle='table'
                    data-toolbar='#toolbar'
                    data-show-refresh='true'
                    data-show-toggle='true'
                    data-sort-name='name'
                    data-sort-order='desc'
                    data-show-columns='true'
                    data-pagination='true'
                    data-search='true'>

         <thead class='thead-inverse'>
           <tr>
              <th data-field='seleccion' data-switchable='false' data-checkbox='true'></th>
              <th data-field='estado' data-switchable='false'></th>   
              <th data-field='pagina' data-sortable='true'>PÀGINA</th>
              <th data-field='codigo' data-sortable='true' data-switchable='false'>CODI</th>
              <th data-field='descripcion' data-sortable='true' data-switchable='false'>DESCRIPCIÓ</th>
               <th data id='image' data-switchable='false'>imatge</th>
               <th data-field='pvp-cat' data-sortable='true'>PVP-CAT</th>
               <th data-field='pvp-lev' data-sortable='true'>PVP-LEV</th> 
               <th data-field='pvp-and' data-sortable='true'>PVP-AND</th>
               <th data-field='pvp-cen' data-sortable='true'>PVP-CEN</th>
               <th data-field='pvp-nor' data-sortable='true'>PVP-NOR</th>
               <th data-field='pvp-vas' data-sortable='true'>PVP-VAS</th>
               <th data-field='fecha-mod' data-sortable='true'>FECHA-MOD</th>
               <th data-field='user' data-sortable='true' data-visible='false'>USER</th>
               <th data-field='edit' data-sortable='false' data-switchable='false'>EDIT</th>
             </tr>
          </thead>
          <tbody>
             <tr>   
                <!— Function to load registres —>       
             </tr>  
          </tbody>
     </table> 


 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(''));
            $search = this.$toolbar.find('.search input');
            $search.off('keyup drop').on('keyup drop', function (event) {
                if (that.options.searchOnEnterKey && event.keyCode !== 13) {
                    return;
                }

                if ($.inArray(event.keyCode, [37, 38, 39, 40]) > -1) {
                    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);
                });
            }
        } 

它不起作用。我认为问题在于搜索工具使用了输入标记和类表单控件,我不确定。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-10-04 11:48:14

也许你正试着像这样做活在这里。我还评论了我添加或更改的地方。顺便说一句,你不需要你在问题中添加的脚本。任何问题在评论中问我。快乐编码:)

代码语言:javascript
复制
$(function(){
$(".search").append('<span class="glyphicon glyphicon-search"></span>');
/* add the span inside search div with append box*/
});
代码语言:javascript
复制
.search {
      width: 25%;
      position: relative;
    }
    
    .search span {
      position: absolute; /*Set search icon*/
      right: 10px;
      top: 10px;
    }
    .search input[type=text]{
      border-color: red; /*Set the border color for search box*/
    }
    .search input[type=text]:focus{
     outline:none;
     box-shadow:none; /*If you dont need the shadow on click*/
    }
    
    .fixed-table-toolbar .bs-bars,
    .fixed-table-toolbar .search,
    .fixed-table-toolbar .columns {
      position: relative;
      margin-top: 10px;
      margin-bottom: 10px;
      line-height: 34px;
    }
代码语言:javascript
复制
<html>
 <head>
  
        <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
        <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.11.0/bootstrap-table.min.css">
</head>
    
    <body>
     <table class='table-bordered' id='tableprod' data-toggle='table' data-toolbar='#toolbar' data-show-refresh='true' data-show-toggle='true' data-sort-name='name' data-sort-order='desc' data-show-columns='true' data-pagination='true' data-search='true'>

  <thead class='thead-inverse'>
    <tr>
      <th data-field='seleccion' data-switchable='false' data-checkbox='true'></th>
      <th data-field='estado' data-switchable='false'></th>
      <th data-field='pagina' data-sortable='true'>PÀGINA</th>
      <th data-field='codigo' data-sortable='true' data-switchable='false'>CODI</th>
      <th data-field='descripcion' data-sortable='true' data-switchable='false'>DESCRIPCIÓ</th>
      <th data id='image' data-switchable='false'>imatge</th>
      <th data-field='pvp-cat' data-sortable='true'>PVP-CAT</th>
      <th data-field='pvp-lev' data-sortable='true'>PVP-LEV</th>
      <th data-field='pvp-and' data-sortable='true'>PVP-AND</th>
      <th data-field='pvp-cen' data-sortable='true'>PVP-CEN</th>
      <th data-field='pvp-nor' data-sortable='true'>PVP-NOR</th>
      <th data-field='pvp-vas' data-sortable='true'>PVP-VAS</th>
      <th data-field='fecha-mod' data-sortable='true'>FECHA-MOD</th>
      <th data-field='user' data-sortable='true' data-visible='false'>USER</th>
      <th data-field='edit' data-sortable='false' data-switchable='false'>EDIT</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <!— Function to load registres —>
    </tr>
  </tbody>
</table>
<!-- Script CDN's-->
   <script type="text/javascript" src="https://code.jquery.com/jquery-3.1.0.min.js"></script>
     <script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
     <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.11.0/bootstrap-table.min.js"></script>

    </body>
</html>

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39847083

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档