我想手動調整表格列的大小。
在 Stack Overflow 上搜索并嘗試
如何使用 jQuery UI和 jQuery UI 使用 table 和 colspans 調整datatables.js 的列大小
和谷歌示例,官方檔案。
https://github.com/dobtco/jquery-resizable-columns & http://jsfiddle.net/Twisty/ah67jopf/3/
我的示例代碼
<table id="examTbl" class="table table-bordered table-hover table-sm dataTable dtr-inline" data-resizable="true">
<thead>
<tr>
<th><input type="checkbox" id="chkbox"></th>
<th>1</th>
<th>2</th>
</tr>
</thead>
</table>
<style>
table, td, th {
/*table-layout:fixed;*/
overflow:hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
</style>
資料表設定
var table_option = {
processing: true,
serverSide: true,
searching: false,
responsive: true,
dom: "lfBtip",
ajax: {
url: '/get/textVal'
},
columns: [{
data: 'null',
defaultContent: "<input type='checkbox' class='chkbox'>",
},
{ data: 'test1' },
{ data: 'test2' },
],
autoWidth: false,
drawCallback: function(settings) {
$('table th').resizable({
handles: 'e',
minWidth: 18,
stop: function(e, ui) {
$(this).width(ui.size.width);
}
});
}
}
uj5u.com熱心網友回復:
我認為您可以在樣式上添加“調整大小”css 屬性。
<table id="examTbl" class="table table-bordered table-hover table-sm dataTable dtr-inline" data-resizable="true">
<thead>
<tr>
<th><input type="checkbox" id="chkbox"></th>
<th>1</th>
<th>2</th>
</tr>
</thead>
</table>
<style>
table, td, th {
/*table-layout:fixed;*/
overflow:hidden;
white-space: nowrap;
text-overflow: ellipsis;
resize:horizontal;
}
uj5u.com熱心網友回復:
編輯:嘗試在您的資料表設定中添加“autoWidth:false”:
var table_option = {
processing: true,
serverSide: true,
searching: false,
autoWidth: false,
responsive: true,
dom: "lfBtip",
ajax: {
url: '/get/textVal'
},
columns: [{
data: 'null',
defaultContent: "<input type='checkbox' class='chkbox'>",
},
{ data: 'test1' },
{ data: 'test2' },
],
autoWidth: false,
drawCallback: function(settings) {
$('table th').resizable({
handles: 'e',
minWidth: 18,
stop: function(e, ui) {
$(this).width(ui.size.width);
}
});
}
}
在這個小提琴中解決:http : //jsfiddle.net/Twisty/ah67jopf/3/
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/354920.html
標籤:javascript 查询 节点.js 数据表 可调整大小
上一篇:jQuery選擇自動格式化
