需求:需要保存用户自己设置的表格列宽
解决:
element文档自带事件
但是呢,我用的是umyui的ux-grid,而umy只是改造了element-ui等等库的表格组,所以umy中ux-grid这个事件返回的参数和element是有区别的,并没有直接返回列宽
经过测试发现返回参数中column里面的width是原宽度,renderWidth是新宽度,于是问题就解决了
主要代码如下:
html:
<ux-grid border
ref="saleBill"
:data="saleBill"
show-overflow
height="500"
show-summary
@header-dragend="changeColumnWidth">
<ux-table-column type="checkbox" width="50" align="center"></ux-table-column>
<ux-table-column field="sort" title="排序" prop="sort" width="50" align="center"></ux-table-column>
<ux-table-column v-for="items in tableHeadList"
:resizable="true" :width="items.width ? items.width : 120"
:field="items.aliasName!=null ? items.aliasName : items.name" :title="items.ZDM"
:key="Math.random()"
:edit-render="items.isEdit == '1' ? {autofocus: '.el-input__inner'} : false" align="center">
<el-input v-if="items.type=='7'" :readonly="mainBill.IsDel_kcsl == 1"
v-model="row[items.name]"
@keyup.native.enter="nextFocus($event,row,items.name,$rowIndex)"></el-input>
</ux-table-column>
</ux-grid>
method:
changeColumnWidth({ column, columnIndex}){
if(column.width != column.renderWidth){
this.tableHeadList[columnIndex-2].width = column.renderWidth
// this.saveHeadConfig()
}
}
I mean, what you say is fundamental and
all. Nevertheless think about if you added some great visuals or videos to give your posts more, "pop"!
Your content is excellent but with pics and video clips, this site
could undeniably be one of the most beneficial in its niche.
Awesome blog!