javascript - 将 dataTable 输入字段宽度设置为自动
问题描述
是否可以将 dataTable 输入设置为自动调整宽度?
我是 ColdFusion 来加载数据的。
<table style="width: 100%;" id="todayTransactionTable" class="table table-hover table-striped table-bordered">
<thead>
<tr>
<th>Date</th>
<th>Beginning Balance</th>
<th>Cash Debit</th>
<th>Wires<BR>Received</th>
<th>Returned<BR>Checks</th>
<th>Redeposits</th>
<th>Ch2</th>
<th>Checks Cashed2</th>
<th>Fees Collected2</th>
<th>Ch3</th>
<th>Checks Cashed3</th>
<th>Fees Collected3</th>
<th>Save</th>
</tr>
</thead>
<tbody>
<cfloop query="getCCTransactions">
<cfoutput>
<tr>
<td>#dateFormat(workdate, 'mm/dd/yyyy')#</td>
<td><input type="number" value="#balance#" step="0.01" /></td>
<td><input type="number" value="#cashorder#" step="0.01" /></td>
<td><input type="number" value="#wires#" step="0.01" /></td>
<td><input type="number" value="#returnedChecks#" step="0.01" /></td>
<td><input type="number" value="#redeposits#" step="0.01" /></td>
<td><input type="number" value="#checks2#" /></td>
<td><input type="number" value="#checksCashed2#" step="0.01" /></td>
<td><input type="number" value="#feesCollected2#" step="0.01" /></td>
<td><input type="number" value="#checks3#" /></td>
<td><input type="number" value="#checksCashed3#" step="0.01" /></td>
<td><input type="number" value="#feesCollected3#" step="0.01" /></td>
<td><a class="mb-2 mr-2 btn-icon btn-pill btn btn-link">Update</button></td>
</tr>
</cfoutput>
</cfloop>
</tbody>
</table>
然后,我在 JavaScript 脚本中设置 dataTable 设置:
<script>
$( document ).ready(function() {
$('#todayTransactionTable').DataTable({
responsive: true,
"pageLength": 50,
"order": [[ 0, "desc" ]]
});
});
</script>
我的问题是输入字段的宽度太大,并且某些列会消失,因为responsive: true
. 如何使输入为自动宽度?
解决方案
推荐阅读
- ios - 使用 POST 请求的 Swift Alamofire
- python - PYTHON3:返回值的缩进
- xml - 如何在经典 ASP 中禁用 DTD 处理以防止 MSSOAP.SOAPClinet30 中的 XXE 攻击
- node.js - Nodejs:在主题交换中使用rabbitmq消息
- c# - 如何从另一个应用程序关闭 WPF 系统托盘应用程序?
- android-studio - 调用接口方法 java.lang.Object[] java.util.Collection.toArray() 时出现 Java NullPointerException
- intellij-idea - 如何获取“保存操作”代码格式以忽略注释
- python - 将元素附加到python中的数组列表之一
- php - 在 Wordpress 中将 SQL Server 表打印到网站?
- javascript - 如何防止带有数字数据的 SQL 注入