Does layui table support self-adaptation?

藏色散人
Release: 2019-07-20 11:53:58
Original
10986 people have browsed it

Does layui table support self-adaptation?

Does layui table support adaptive?

layui table does not support adaptive. For example, when adding a data table to the page, you will find that the width of each column of the data table cannot adapt to the table, and they are all crowded together. After reading the official documentation, I found that the column width can be set for the table:

layuiTable.render({
width: 710,
elem: '#tabSta',
url: "/pickTicket/tytr", 
cols: [[
{ field: "ShiftsID", title: "班次ID", hide: true },
{ field: "scheduleCoding", title: "班次", align: "center" },
{ field: "time", title: "时间", align: "center" },
{ field: "carNumber", title: "车辆编号", align: "center" } 
]],
});
Copy after login

However, here comes the problem. When I shrink the page, the width of the table is still the original width and cannot meet the adaptive size requirements. The reason is that the width I just set to it is a fixed size width.

Since the above method does not work, then proceed to the second solution. I checked on the browser page and found that when the width is set to 100%, the width of the data table can be adaptively resized. Therefore, add the parameter done to the corresponding code of the data table to customize a style for the data table.

The relevant code is as follows:

tabrecord =layuiTable.render({
elem: ‘#tabStation’,
url: “/pickTicket/tytr”,
done: function (res, curr, count){
KaTeX parse error: Expected 'EOF', got '}' at position 34: …th", "100%"); }̲, cols: [[ { fi…(“table”).css(“width”, “100%”);
Copy after login

You can also write $("table").width("100%") like this.

With this setting, we return to the browser page to view it. No matter how we zoom the page, the data table can adapt to the page size.

For more technical articles related to Layui, please visit the Layui Framework Tutorial column to learn!

The above is the detailed content of Does layui table support self-adaptation?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!