Happy-Coding-Clans / vue-easytable

A powerful data table based on vuejs. You can use it as data grid、Microsoft Excel or Google sheets. It supports virtual scroll、cell edit etc.
https://happy-coding-clans.github.io/vue-easytable/
MIT License
3.64k stars 726 forks source link

宽度设置 #32

Closed sunriseyuen closed 6 years ago

sunriseyuen commented 6 years ago

{field: 'name', title:'姓名', width: 100} 栏位的宽度不应该是像数,后台给数据关注的是内容的宽度,比如某个栏位的适中宽度是60或是120,至于前端是用什么字体大小,后台不清楚,所以这个with用于定位为字符宽度更为合适,然后前端根据字体大小 比如宽度*12,是前端所需要的宽度。

huangshuwei commented 6 years ago

这样有很多局限性 1、表格内有很多行数据,每一行的每一列都要遍历一遍,取最大值?效率低下,并且如果存在某一列内容非常多,根据这列设置宽度肯定不合适

我觉得你可以参考固定列+自适应的设置(http://doc.huangsw.com/vue-easytable/app.html#/table?anchor=table-complex-table-resize): 每一列设置较小的宽度,表格容器大于当前总宽度(每一列的最小宽度之和)时自适应展示; 当表格容器小于当前总宽度(每一列的最小宽度之和)时固定列展示

sunriseyuen commented 6 years ago

你误会我的意思, {field: 'name', title:'姓名', width: 100} 这里还是有一个width,但这个width不是指橡数,而是指字符宽度,如果你用12号字体就 用widthX12,用14号字体就用widthX14,后台一个数据可能供不同的客户端使用。

huangshuwei commented 6 years ago

哦,明白你意思了😁,是个不错的主意。不过我要好好想想,因为和现在的实现方式不同,后面想想做适配能否实现

sunriseyuen commented 6 years ago

initColumns时加一个回调接口就可以,这样不需要做修改。

huangshuwei commented 6 years ago

@sunriseyuen 欢迎提个PR😊,记得用最新版本