0
我的表的設計是,這將有大約100列,並且部分將有大約4行使用固定頭和列的JQuery
我想有一個固定的頭和一些列凍結。我能夠通過使用CSS表達式來實現。
CSS表達式打破IE10,並使頁面很慢,所以我想實現使用jQuery相同的,但我沒能實現它
我附上HTML(去除了大部分的爲了清楚起見)和CSS。鎖定類是什麼定義鎖定
div id="main-container" style="overflow: scroll; height: 366px; width: 1023">
<table id="tbl" style="table-layout: fixed">
<thead id="mainTbleHdId">
<tr>
<th class="locked"></th>
<th class="locked"></th>
<th class="locked">Item Details</th>
<th class="locked"></th>
<th></th>
.
.
.
.
<th></th>
</tr>
<tr class="xxxxx">
<th class="locked">Select Item(s)</th>
<th class="locked">Select Decision</th>
<th class="locked">Select Select</th>
<th class="locked">Select Description</th>
.
.
.
<th >Select Prep</th>
</tr>
<tr>
<th id="itemView" class="locked" >
<input name="selectAll" id="selectAll" type="checkbox">All</th>
<th class="locked"></th>
<th class="locked"></th>
<th class="locked"></th>
.
.
.
.
<th ></th>
</tr>
<tr >
<th class="locked"></th>
<th class="locked"></th>
<th class="locked"></th>
<th class="locked"></th>
.
.
.
.
<th >Select Calc</th>
</tr>
</thead>
<tbody id="mainTbleBoyId">
<tr class="Rows">
<td id="singleSelctcheckboxtd0" class="locked">
<input name="Checkbox" type="checkbox">
</td>
<td class="locked">
<select name="selectNamebuyerDecision">
<option value="Please Select" name="buyerCheck" selected="selected">Please Select</option>
</select>
</td>
<td class="locked" id="dpcitd0">
<input type="text" value="98070702">
</td>
<td class="locked" id="genDesctd0">
<input type="text" value="ATHLETIC">
</td>
.
.
.
.
<td class="InputType" id="liquidationPreptd0">
<input type="text" value="0">
</td>
</tr>
</tbody>
</table>
</div>
CSS
TABLE#tbl {
BORDER-COLLAPSE: collapse; TABLE-LAYOUT: fixed
}
THEAD TH {
POSITION: relative;
}
THEAD TR.nosort TD {
POSITION: relative;
}
THEAD TH.first{
}
Table#tbl THEAD TD {
Z-INDEX: 20; TOP: expression(document.getElementById("main-container").scrollTop-2)
}
Table#tbl THEAD TH {
Z-INDEX: 20; TOP: expression(document.getElementById("main-container").scrollTop-2)
}
Table#tbl THEAD TH.locked {
Z-INDEX: 30
}
Table#tbl THEAD TD.locked {
Z-INDEX: 30
}
TD.locked {
Z-INDEX: 5; POSITION: relative; LEFT: expression(parentNode.parentNode.parentNode.parentNode.scrollLeft)
}
TH.locked {
Z-INDEX: 5; POSITION: relative; LEFT: expression(parentNode.parentNode.parentNode.parentNode.scrollLeft)
}
Table#tbl THEAD TH.locked {
POSITION: relative; TEXT-ALIGN: center; BACKGROUND-COLOR: #60487A; COLOR: black; CURSOR: default; border-bottom: 1px solid black;border-right: 1px solid black;
}
Table#tbl THEAD TD.locked {
POSITION: relative;
}
Table#tbl TBODY TD.locked {
POSITION: relative; TEXT-ALIGN: center; BACKGROUND-COLOR:white; COLOR: black; CURSOR: default;
}
我試圖做這樣的事情
$("#main-container").scroll(function() {
var xx = document.getElementById("main-container").scrollTop-2;
$("#mainTbleHdIdtr").each(function() {
$(this).find("th").each(function() {
$(this).css({'zIndex':20,"TOP":xx});
});
});
});
模擬jQuery中鎖定,但它似乎不工作 我已經嘗試了一些插件和數據表,問題是,當我使用Fixe時,數據表使頁面非常慢d柱
在此先感謝
我試過使用數據表,但在加載時,我們做FixedColumns花費的時間約爲15秒,而沒有固定的顏色它的baout 2秒 –
我沒有任何性能問題,當我實現它與35列以上和45行。你是否撕掉了你用來試圖修復頭部的CSS? – Brocco
我沒有刪除所有的CSS,datatables很快沒有固定的列,但減慢了很多固定的列 –