使工作台100%用智能表角固定头 [英] Make table 100% with fixed header with smart table angular

查看:209
本文介绍了使工作台100%用智能表角固定头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://plnkr.co/edit/GIeXoF?p=$p$ PVIEW

我怎样才能让这台以100%的高度的高度,但仍然头必须保持固定的吗?

 <!DOCTYPE HTML>
< HTML NG-应用=对myApp>  < HEAD>
    <链路数据需要=bootstrap-css@3.2.0数据semver =3.2.0的rel =stylesheet属性HREF =// maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap .min.css/>
    &所述;脚本数据需要=angular.js@1.2.25数据semver =1.2.25SRC =的https://$c$c.angularjs.org/1.2.25/angular.js&GT ;< / SCRIPT>
    <链接rel =stylesheet属性HREF =style.css文件/>
    &所述; SCRIPT SRC =的script.js>&下; /脚本>
    <脚本SRC =智能table.debug.js>< / SCRIPT>
  < /头>  <机身NG控制器=mainCtrl>
    <表类=表的表条纹>
    <&THEAD GT;
    &所述; TR>
        百分位ST-比=20ST-排序=名字>首先名和LT; /第i
        百分位ST-比=20ST-排序=姓氏>姓氏和LT; /第i
        百分位ST-比=10ST-排序=年龄>年龄< /第i
        百分位ST比例=30ST-排序=电子邮件>电子邮件< /第i
        百分位ST-比=20ST-排序=平衡>余量< /第i
    < / TR>
    < / THEAD>
    <&TBODY GT;
    < TR NG重复=行中显示>
        &所述; TD ST-比=20> {{row.firstName}}&下; / TD>
        &所述; TD ST-比=20> {{row.lastName |大写}}< / TD>
        &所述; TD ST-比=10> {{row.age}}&下; / TD>
        &所述; TD ST-比=30> {{row.email}}&下; / TD>
        &所述; TD ST-比=20> {{row.balance |货币}}< / TD>
    < / TR>
    < / TBODY>
    <&TFOOT GT;
    &所述; TR>
        < TD合并单元格=5级=TEXT-中心>
            < D​​IV ST-项目逐页=20ST-分页=>< / DIV>
        < / TD>
    < / TR>
    < / TFOOT>
< /表>  < /身体GT;< / HTML>表{
    箱尺寸:边界盒;
    -moz-箱尺寸:边界盒;
    显示:弯曲;
    柔性方向:列;
    调整项目:舒展;
    高度:500像素; / *这可以改变* /
}表* {
    箱尺寸:继承;
    -moz-箱尺寸:继承;
}THEAD {
    显示:弯曲;
    柔性方向:列;
    调整项目:舒展;
}TBODY {
    溢出-Y:滚动;
    显示:inline-block的;
}THEAD> TR,TBODY> TR,TFOOT> TR {
    显示:弯曲;
    柔性方向:排;
    柔性包装:NOWRAP;
}THEAD,TFOOT {
    弯曲收缩:0;
}日TBODY TD {
    宽度:20%; / *这可以改变* /
    溢出 - X:隐藏;
    文本溢出:省略号;
    显示:inline-block的;
}TFOOT {
    显示:inline-block的;
}TFOOT TD {
    宽度:100%;
    显示:inline-block的;
}


解决方案

我找到的解决方案是创建一个包含只有标题另一个表,所以当我在假头CLIC对智能抛出一个JS比火灾CLIC事件 - 表头。通过这种方式,你可以使用去ST-排序指令。
这是一个肮脏的解决方案,但工程。我的例子有宽度为100%,并没有100%的高度,但我希望这有助于你的头。

 <表ID =的tableHeader级=表浓缩>
            <&THEAD GT;
                &所述; TR角色=的rowHeader>
                    <! - < I类=发发排序>< / I> - >
                    百分位类=排序ST-比率=10的onclick =fire_clic(1)> IdCustomer< I类=图标排列图标小>< / I>< /第i
                    百分位类=排序ST-比率=35的onclick =fire_clic(2)>名称< I类=图标排列图标小>< / I>< /第i
                    百分位ST比例=15>硝苯地平< /第i
                    百分位类=排序ST-比率=15的onclick =fire_clic(4)>电话和LT; I类=图标排列图标小>< / I>< /第i
                    百分位类=排序ST-比率=25的onclick =fire_clic(5)>电子邮件和LT; I类=图标排列图标小>< / I>< /第i ;
                < / TR>
            < / THEAD>
        < /表>        < D​​IV CLASS =表容器>            <表ST-坚持=tableLSST-表=客户ST-安全-SRC =rowCustomerCollectionST-分页,滚动ST管=callServer
                   类=table表条纹表悬停表浓缩>                < THEAD数据-NG-隐藏=真>
                    &所述; TR>
                        百分位的id =的col1ST-比=10ST-排序=IdCustomer和SEQ ID&下; /第i
                        百分位ID =COL2ST-比率=35ST-排序=NOM>名称和LT; /第i
                        百分位ST比例=15>硝苯地平< /第i
                        百分位ID =COL4ST-比率=15ST-排序=电话>电话和LT; /第i
                        百分位ID =COL5ST-比率=25ST-排序=dPer3>电子邮件和LT; /第i
                    < / TR>
                < / THEAD>                <&TBODY GT;
                    < TR数据-NG-重复=C客户>
                        < TD ST-比=10标题=转到客户级=艾拉的数据-NG-点击=打开(c.idCustomer)>
                            {{c.idCustomer}}
                        < / TD>
                        < TD ST比例=35> {{c.nom}}< / TD>
                        < TD ST比例=15> {{c.nif}}< / TD>
                        < TD ST比例=15> {{c.phone}}< / TD>
                        < TD ST比例=25> {{c.dPer3}}< / TD>
                    < / TR>
                < / TBODY>            < /表>        < / DIV><脚本>
        功能fire_clic(ID,ELEM){
        VAR idControl ='日[ID = COL'+ ID +']';        //火智能表CLIC事件
        $(idControl).trigger('点击');
    }
< / SCRIPT>

CSS:

  #tableHeader {
    宽度:100%;
}。表容器{
    高度:500像素;
    宽度:100%;
    溢出-Y:滚动;
    空格:NOWRAP;
    字体大小:小;
    调整项目:舒展;
}。表冷凝> TBODY> TR> TD {
    填充:2px的;
}

http://plnkr.co/edit/GIeXoF?p=preview

How can I make this table with a height of 100% height but the header must still remain fixed?

<!DOCTYPE html>
<html ng-app="myApp">

  <head>
    <link data-require="bootstrap-css@3.2.0" data-semver="3.2.0" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" />
    <script data-require="angular.js@1.2.25" data-semver="1.2.25" src="https://code.angularjs.org/1.2.25/angular.js"></script>
    <link rel="stylesheet" href="style.css" />
    <script src="script.js"></script>
    <script src=smart-table.debug.js></script>
  </head>

  <body ng-controller="mainCtrl">
    <table  class="table table-striped">
    <thead>
    <tr>
        <th st-ratio="20" st-sort="firstName">first name</th>
        <th st-ratio="20" st-sort="lastName">last name</th>
        <th st-ratio="10" st-sort="age">age</th>
        <th st-ratio="30" st-sort="email">email</th>
        <th st-ratio="20" st-sort="balance">balance</th>
    </tr>
    </thead>
    <tbody>
    <tr ng-repeat="row in displayed">
        <td st-ratio="20">{{row.firstName}}</td>
        <td st-ratio="20">{{row.lastName | uppercase}}</td>
        <td st-ratio="10">{{row.age}}</td>
        <td st-ratio="30">{{row.email}}</td>
        <td st-ratio="20">{{row.balance | currency}}</td>
    </tr>
    </tbody>
    <tfoot>
    <tr>
        <td colspan="5" class="text-center">
            <div  st-items-by-page="20" st-pagination=""></div>
        </td>
    </tr>
    </tfoot>
</table>

  </body>

</html>

table {
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    height: 500px; /* this can vary */
}

table * {
    box-sizing: inherit;
    -moz-box-sizing: inherit;
}

thead {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

tbody {
    overflow-y: scroll;
    display: inline-block;
}

thead > tr, tbody > tr, tfoot > tr {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
}

thead, tfoot {
    flex-shrink: 0;
}

th, tbody td {
    width: 20%; /* this can vary */
    overflow-x: hidden;
    text-overflow: ellipsis;
    display: inline-block;
}

tfoot {
    display: inline-block;
}

tfoot td {
    width: 100%;
    display: inline-block;
}

解决方案

The solution I found was to create another table which contains only the header, so when I clic on the fake header throw a JS than fires clic event on the smart-table header. In this way you can use de st-sort directive. It's a dirty solution but works. My example has width at 100% and hasn't 100% height but I hope this helps you with the header.

 <table id="tableHeader" class="table-condensed">
            <thead>
                <tr role="rowheader">
                    <!--<i class="fa fa-sort"></i>-->
                    <th class="sorting" st-ratio="10" onclick="fire_clic(1)">IdCustomer<i class="icon-sort icon-small"></i></th>
                    <th class="sorting" st-ratio="35" onclick="fire_clic(2)">Name<i class="icon-sort icon-small"></i></th>
                    <th st-ratio="15">Nif</th>
                    <th class="sorting" st-ratio="15" onclick="fire_clic(4)">Phone<i class="icon-sort icon-small"></i></th>
                    <th class="sorting" st-ratio="25" onclick="fire_clic(5)">Email <i class="icon-sort icon-small"></i></th>
                </tr>
            </thead>
        </table>

        <div class="table-container">

            <table st-persist="tableLS" st-table="customers" st-safe-src="rowCustomerCollection" st-pagination-scroll st-pipe="callServer"
                   class="table table-striped table-hover table-condensed">

                <thead data-ng-hide="true">
                    <tr>
                        <th id="col1" st-ratio="10" st-sort="IdCustomer">ID</th>
                        <th id="col2" st-ratio="35" st-sort="nom">Name</th>
                        <th st-ratio="15">Nif</th>
                        <th id="col4" st-ratio="15" st-sort="tel">Phone</th>
                        <th id="col5" st-ratio="25" st-sort="dPer3">Email</th>
                    </tr>
                </thead>

                <tbody>
                    <tr data-ng-repeat="c in customer">
                        <td st-ratio="10" title="Go to customer" class="irA" data-ng-click="open(c.idCustomer)">
                            {{c.idCustomer}}
                        </td>
                        <td st-ratio="35">{{c.nom}}</td>
                        <td st-ratio="15">{{c.nif}}</td>
                        <td st-ratio="15">{{c.phone}}</td>
                        <td st-ratio="25">{{c.dPer3}}</td>
                    </tr>
                </tbody>

            </table>

        </div>

<script>
        function fire_clic(id, elem) {
        var idControl = 'th[id=col' + id + ']';

        //Fire the clic event in smart-table
        $(idControl).trigger('click');
    }
</script>

CSS:

#tableHeader {
    width: 100%;
}

.table-container {
    height: 500px;
    width: 100%;
    overflow-y: scroll;
    white-space: nowrap;
    font-size: small;
    align-items: stretch;
}

.table-condensed > tbody > tr > td {
    padding: 2px;
}

这篇关于使工作台100%用智能表角固定头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆