javascript - Datatable contenteditable问题导致scrollX
问题描述
我对 contenteditable 有疑问。
当我在列上使用 contenteditable 并且启用 scrollX 选项时,列未对齐。看我的截图错位了
我在stackoverflow上尝试了很多解决方案,但都没有成功。
但是,这是我的 dataTable 设置:
table = $('#sparepart_id').DataTable({
"paging": true,
"stateSave": true,
"pagingType": "full_numbers",
"lengthChange": false,
"searching": false,
"ordering": true,
"info": false,
"autoWidth": false,
"pageLength": 12,
scrollX: true,
"initComplete": function (settings, json) {
$("#sparepart_id").wrap("<div style='overflow:auto; width:100%;position:relative;'></div>");
},
stateLoadCallback: function (settings) {
var o;
$.ajax( {
url : BASE_URL+"spareparts/load_layout",
type : "POST",
data : { module_table : "sparepart-list"},
async : false,
dataType: 'json',
success: function (json) {
o = JSON.parse(json.json);
},
error:function(data){
console.log(data);
}
} );
return o;
}
在我的 HTML 代码中
<td contenteditable="true"></td>
解决方案
不必将此标记为解决方案,也不必投票。这个答案是由这个问题的作者找到的。我列出了这个,以保留 SO 中遵循的问答模式
.class{
word-break: break-all !important;
cursor: text;
white-space: pre-wrap !important;
}
推荐阅读
- rust - 由于过滤 read_dir 输出,如何解决“无法移出借来的内容”?
- linphone - 我使用 linphone Mediastreamer2 发送 rtp 来听到这样的语音错误代码
- selenium-webdriver - 无法生成唯一范围报告我使用过 SimpleDateFormat 类
- elixir - Enum.each 在循环 ExUnit 测试时丢失变量
- javascript - 是否建议添加到全局窗口对象?
- ios - 在 iPad 2019 iOS v12.2 上的 Mobile Safari 上打开一个 url
- android - Volley 错误的 URL - 如何解决?
- python-3.x - “工作表”对象没有属性“max_col”
- python - 根据第一个索引循环遍历数组
- sql - 透视排名表