成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

Qt TableWidget 固定表頭 實(shí)例

移動(dòng)開(kāi)發(fā)
本文介紹的是Qt TableWidget 固定表頭 實(shí)例,很多時(shí)候我們都在用列表,不多說(shuō),先哎看本文內(nèi)容。

Qt TableWidget 固定表頭 實(shí)例是本文要介紹的內(nèi)容,使TableWidget  固定表頭一個(gè)js插件的實(shí)例,先來(lái)看內(nèi)容。

公司項(xiàng)目里面很多地方都需要用到,出列表的時(shí)候固定表頭,滾動(dòng)表體,思路就是動(dòng)態(tài)創(chuàng)建一個(gè)div,然后里面創(chuàng)建2個(gè)div,一個(gè)title,一個(gè)body,然后用clone的方法,分別處理2個(gè)div的內(nèi)容

使用說(shuō)明:

  1. var tableWidget = new TableWidget("TableID", "DestID", "100%", "300px");  
  2. tableWidget.change(); 

表格需要固定寬度,table 需要加 style="table-layout: fixed;"

  1. /*  
  2. * 函數(shù)名稱: Widget  
  3. * 作    者: yithcn  
  4. * 功能說(shuō)明: 固定表格頭,表體可以滾動(dòng)  
  5. * 創(chuàng)建日期: 2010.10.13  
  6. */  
  7. function TableWidget(table, dest, width, height) {  
  8.     this.construct(table, dest, width, height);  
  9. };  
  10. TableWidget.prototype = {  
  11.     table: null,  
  12.     dest: null,  
  13.     widht: null,  
  14.     height: null,  
  15.     tdiv: null,  
  16.     bdiv: null,  
  17.     create: function() {  
  18.         var that = this;  
  19.         var div = document.createElement("div");  
  20.         div.style.cssText = "background-color:white;width:" + that.width;  
  21.         that.dest.appendChild(div);  
  22.         //title  
  23.         var titlediv = document.createElement("div");  
  24.         titlediv.style.cssText = "width:100%;";  
  25.         div.appendChild(titlediv);  
  26.         //body  
  27.         var bodydiv = document.createElement("div");  
  28.         bodydiv.style.cssText = "overflow:auto;height:" + that.height + ";";  
  29.         bodydiv.appendChild(that.table);  
  30.         div.appendChild(bodydiv);  
  31.         var newtable = that.table.cloneNode(true);  
  32.         var len = newtable.rows.length;  
  33.         for (var i = len - 1; i > 0; i--) {  
  34.             newtable.deleteRow(i);  
  35.         }  
  36.         titlediv.appendChild(newtable);  
  37.         that.table.deleteRow(0);  
  38.         that.tdiv = titlediv;  
  39.         that.bdiv = bodydiv;  
  40.     },  
  41.     construct: function(table, dest, width, height) {  
  42.         var that = this;  
  43.         window.onload = function() {  
  44.             if (table && typeof table == "string")  
  45.                 table = document.getElementById(table);  
  46.             if (dest && typeof dest == "string")  
  47.                 dest = document.getElementById(dest);  
  48.             else  
  49.                 dest = document.body;  
  50.             widthwidth = width || "100%";  
  51.             heightheight = height || "300px";  
  52.             height = parseInt(height) - table.rows[0].offsetHeight;  
  53.             that.table = table;  
  54.             that.dest = dest;  
  55.             that.width = width;  
  56.             that.height = height;  
  57.             that.create();  
  58.             that.change();  
  59.         }  
  60.     },  
  61.     change: function() {  
  62.         var that = this;  
  63.         if (that.table.offsetHeight > parseInt(that.height)) {  
  64.             that.tdiv.style.width = parseInt(that.bdiv.offsetWidth) - 16;  
  65.         }  
  66.         else {  
  67.             that.tdiv.style.width = parseInt(that.bdiv.offsetWidth);  
  68.         }  
  69.     }  
  70. }; 

之所以會(huì)有一個(gè)change方法,是因?yàn)樵陧?xiàng)目當(dāng)中需要?jiǎng)討B(tài)改變列表,要計(jì)算表頭和表體滾動(dòng)條。

小結(jié):Qt TableWidget 固定表頭 實(shí)例的內(nèi)容介紹完了, 希望本文對(duì)你有所幫助!

責(zé)任編輯:zhaolei 來(lái)源: 互聯(lián)網(wǎng)
相關(guān)推薦

2011-06-30 14:34:17

QT Tablewidge QTableWidg

2011-06-30 16:53:18

QT Creator TableWidge

2009-06-23 11:23:13

DataTableJSF動(dòng)態(tài)生成

2011-07-05 14:46:34

2011-06-14 16:45:57

Qt 圖標(biāo)

2011-06-24 14:34:17

Qt 小票 打印

2011-06-13 16:51:19

Qt Socket

2011-06-27 16:07:49

Qt Designer

2011-06-21 09:33:49

Qt 啟動(dòng) 界面

2011-07-05 15:16:00

QT 進(jìn)度條

2011-06-30 18:15:36

Qt 線程 同步

2011-06-16 17:54:30

Qt Mplayer

2011-06-30 11:07:02

Qt QTextEdit

2011-06-27 16:37:08

Qt Designer

2014-08-26 11:46:46

QtAndroid實(shí)例教程

2011-06-14 10:52:10

QT QTreeView

2011-06-21 15:11:04

QT 數(shù)據(jù)庫(kù)

2011-06-30 16:38:07

Qt QTableWidg

2011-06-30 17:31:32

Qt 多線程 信號(hào)

2011-07-05 17:54:43

QT Sqlite ARM
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)

主站蜘蛛池模板: 国产亚洲成av人在线观看导航 | 日韩最新网址 | 欧美一区二区成人 | 中文字幕在线剧情 | 久久网国产 | 国产精品久久久久久久免费大片 | 国产精品免费一区二区三区四区 | 午夜男人天堂 | 午夜电影在线播放 | 久久久久久久久久久91 | 欧美日韩国产三级 | 中文字幕一区在线 | 国产日韩一区二区 | 亚洲免费观看视频 | 天天干天天色 | 久久久国产一区二区三区 | 91视频国产精品 | 欧美日韩视频在线播放 | 91亚洲国产精品 | 天天操操操操操 | 国产永久免费 | 三级黄色片在线播放 | 国产精品亚洲二区 | 黄色免费av | 亚洲精品国产精品国自产在线 | 久久国产精99精产国高潮 | 亚洲一区精品视频 | 日韩精品免费 | www性色 | 久久av一区二区三区 | 五月天综合网 | 一区二区三区亚洲 | 精品日本久久久久久久久久 | 999国产视频| 在线观看视频一区二区三区 | 亚洲一区在线日韩在线深爱 | 一级黄色片免费在线观看 | 韩国精品在线 | 亚洲女人天堂成人av在线 | 欧美成人aaa级毛片在线视频 | 久久久久久国产精品免费免费 |