DataTables defining the self-adapting method of column widths

Source: Internet
Author: User

Different resolutions and browser-adaptive, the list does not appear scroll bar, the table content wrap.
Method: By defining the table column properties, combining the <TABLE>CSS style and the defined column cell style  ' Td_huanhang '/' Td_unhuanhang '
"Columndefs": [
{targets:9, Orderable:false, Width: "10%"},
]
Columns: [
{"Data": "Addr", "name": "Addr", ClassName: "Td_unhuanhang",
Render:function (data, type, row, meta) {
    if (data!=null) {
            return type = = = ' Display ' && data.length > 10?
            ' <div title= ' ' +data+ ' > ' +data.substr (0) + ' ...</div> ': data;
        Return ' <div title= ' +data+ ' > ' +data+ ' </div> ';
    }
    else{
        Return ';
    }
}
}
]
<table class= "Table table-striped table-bordered table-hover no-margin text-center" style= "table-layout:fixed;" >
</table>

After this operation, the table is fixed width, but the inside of the article if very long, the text will still run out

Workaround:

Add style= in TD "Word-wrap:break-word;" Wrap it up, if you don't want to wrap, you can set the out-of-content to hide and use ellipses instead

. td_huanhang{
/* Line Break */
Word-wrap:break-word;
}
. Td_unhuanhang > div{
/* No line break, ellipsis instead of */
// the text does not wrap, and the text continues on the same line until the <br> tag is encountered.
Overflow:hidden;
//...
}




From for notes (Wiz)

DataTables defining the self-adapting method of column widths

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.