如何为jQuery DataTables中的特定列设置最大宽度 [英] How to set max-width for particular column in jQuery DataTables

查看:1040
本文介绍了如何为jQuery DataTables中的特定列设置最大宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为一个特定的列设置最大宽度,所有其他列应自动调整大小.我已经尝试了以下代码,但由于我认为没有最大宽度"属性,因此无法正常工作

How do I set a max width for one specific column, all the other columns should be auto sized. I have tried the below code, but it does not work since I think there is no 'max-width' attribute

$('#table').dataTable({
    'paging': false,
    'info': false,
    'searching': false,
    'columnDefs': [
      {'max-width': '320px', 'targets': 'my-column'}
    ],
});

推荐答案

尝试类似的方法

最大宽度选项提及宽度百分比

max-width option mention the width percentage

目标选项提及字段索引

$('#table').dataTable({
    'paging': false,
    'info': false,
    'searching': false,
    'columnDefs': [
      {'max-width': '20%', 'targets': 0}
    ],
});

这篇关于如何为jQuery DataTables中的特定列设置最大宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆