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

Qt TableWidget 固定表頭 實例

移動開發
本文介紹的是Qt TableWidget 固定表頭 實例,很多時候我們都在用列表,不多說,先哎看本文內容。

Qt TableWidget 固定表頭 實例是本文要介紹的內容,使TableWidget  固定表頭一個js插件的實例,先來看內容。

公司項目里面很多地方都需要用到,出列表的時候固定表頭,滾動表體,思路就是動態創建一個div,然后里面創建2個div,一個title,一個body,然后用clone的方法,分別處理2個div的內容

使用說明:

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

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

  1. /*  
  2. * 函數名稱: Widget  
  3. * 作    者: yithcn  
  4. * 功能說明: 固定表格頭,表體可以滾動  
  5. * 創建日期: 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. }; 

之所以會有一個change方法,是因為在項目當中需要動態改變列表,要計算表頭和表體滾動條。

小結:Qt TableWidget 固定表頭 實例的內容介紹完了, 希望本文對你有所幫助!

責任編輯:zhaolei 來源: 互聯網
相關推薦

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動態生成

2011-07-05 14:46:34

2011-06-27 16:07:49

Qt Designer

2011-06-21 09:33:49

Qt 啟動 界面

2011-06-14 16:45:57

Qt 圖標

2011-06-24 14:34:17

Qt 小票 打印

2011-06-13 16:51:19

Qt Socket

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實例教程

2011-07-05 15:16:00

QT 進度條

2011-06-30 18:15:36

Qt 線程 同步

2011-06-30 17:31:32

Qt 多線程 信號

2011-06-30 16:38:07

Qt QTableWidg

2011-06-14 10:52:10

QT QTreeView

2011-06-21 15:11:04

QT 數據庫

2011-07-05 16:08:10

點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 国外成人在线视频网站 | www.888www看片 | 中文字幕免费视频 | 黄色免费网站在线看 | 美美女高清毛片视频免费观看 | 99精品一级欧美片免费播放 | 久久精品亚洲欧美日韩久久 | 国产一区二区三区四区在线观看 | 91高清在线| 日韩精品在线看 | 在线免费激情视频 | 理论片87福利理论电影 | 国产精品成人久久久久 | www.国产.com| 精品久久久久久久久亚洲 | 日韩欧美一区二区三区四区 | 色综合99| 一区二区日本 | 久久国产秒| 国产精品一二三区 | 午夜大片 | 国产午夜精品福利 | 91精品一区 | 精品久久av | 国产偷录视频叫床高潮对白 | 久久99精品久久久久久 | 精品免费国产视频 | 久久精品欧美一区二区三区不卡 | 亚洲国产成人av好男人在线观看 | 国产午夜影院 | 亚洲成人免费网址 | 亚洲午夜av久久乱码 | 日韩不卡一二区 | www九色 | 人操人人干人 | 日本国产欧美 | 成人在线日韩 | 中文字幕av在线 | 在线视频h | 国产一区二区三区www | 91精品一区二区三区久久久久久 |