Sample Code for Row Height setting by dataGrid in JQuery

Source: Internet
Author: User

Copy codeThe Code is as follows:
Columns :[[
{Field: "activitycontent", title: 'activity content', width: fixWidth (0.18), align: "center", halign: "center ",
Formatter: function (value, rec ){
If (value. indexOf ("src") <0 ){
If (rec. activitycontent. length> Math.ceil(document.doc umentElement. clientWidth * 0.18)/11.5)
Return rec.activitycontent.substring(0, math.ceil(document.doc umentElement. clientWidth * 0.18/11.5) + '..';
Else
Return rec.activitycontent.substring(0, math.ceil(document.doc umentElement. clientWidth * 0.18/11.5 ));
}
}
},
{..}
]

Note that the activitycontent and 0.18 must have the same parameter ratio of 11.5. You can test and adjust the ratio by yourself. Here, we use this parameter to integer Chinese characters.
If the text content is greater than the length, the result is
Test length 8 test length 74 test ..
Otherwise
Test length 8 test length 74 Test

Related Article

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.