IE 瀏覽器中,DataGrid 啟用行編輯模式時,編輯器內的輸入框、下拉框等控件隨著垂直滾動條滾動而脫離單元格位置,懸浮在頁面上。
**EasyUI 版本過舊**。1.4.1 及以上版本已修復此 IE 專有渲染 Bug。舊版本 (1.3.x, 1.2.x) 在 IE 的 position: absolute 定位計算上有缺陷,滾動時未重新計算編輯器座標。
jquery.easyui.min.js、easyui.css、icons.css、images/ 目錄<!-- 僅針對 IE -->
<!--[if IE]>
<style>
.datagrid-editor {
position: relative !important; /* 強制相對定位 */
}
.datagrid-row-editing .datagrid-cell {
overflow: visible !important; /* 防止裁剪 */
}
</style>
<![endif]-->
// 在 onAfterEdit / onBeginEdit 事件中
$('#dg').datagrid({
onBeginEdit: function(index, row) {
// 強制瀏覽器重繪
setTimeout(function() {
var editors = $('#dg').datagrid('getEditors', index);
editors.forEach(function(ed) {
$(ed.target).css('position', 'relative');
});
}, 0);
}
});
確保 DataGrid 在 固定高度容器 中,而非 fit: true 的全屏 layout 直接包裹:
<div style="height: 500px; overflow: auto;"> <!-- 固定高度容器 -->
<table id="dg" class="easyui-datagrid"></table>
</div>
| 版本 | IE 浮動 Bug | 建議 |
|---|---|---|
| 1.2.x - 1.3.x | 嚴重 | 必須升級 |
| 1.4.0 | 部分修復 | 建議升級 |
| 1.4.1+ | 已修復 | 生產可用 |
| 1.5.x / 1.10.x | 無 | 推薦使用 |
**不要在 2024 年繼續維護 EasyUI 1.x 舊專案**。考慮遷移至: