Element table使用技巧详解
1、控制table某些行数不显示
下载附件的需求,有些行有附件,有些没有,所以需要过滤,重点是:Array.filter()使用
<el-card :body-style="{ padding: '20px 10px' }">
<h5>附件列表</h5>
<el-table :data="quesObj.filter(item => item.attach)">
<el-table-column label="附件名称" align="center">
<template slot-scope="scope">
<a :download="scope.row.attach" :href="'/api/hbase/readFile?fileName=' + scope.row.attach">{{scope.row.attach}}</a>
</template>
</el-table-column>
</el-table>
</el-card>
2、elementUI的table自定义合计方法
//1、table上添加summary-method自定义计算方法
<el-table
class="orderStyle"
:show-summary = "userInfo && userInfo.roleName === 'user'"
:summary-method="totalRule"
ref="order"
:data="orderData"
@selection-change="handleSelectionChange"> //2、选择的行数据
handleSelectionChange(rows){
this.orders = rows
}, //3、合计规则:注意return的是与列对应的数组
totalRule(){
let sum =
this.orders.forEach(item => {
sum += item.price
})
return ['合计','','','',sum,'']
},
3、elementUi的tabel组件如果要显示合计的话,下面的prop是必须得加的
<el-table-column label="服务价格" prop="service_price">
<template slot-scope="scope">{{scope.row.service_price}}</template>
</el-table-column>
4、elementUi的tabel组件复选框控制禁止选择
<el-table-column
type="selection"
width=""
:selectable='checkboxInit'>
</el-table-column> //methods里
checkboxInit(row,index){
if (row.withdrawState==)//这个判断根据你的情况而定
return ;//不可勾选,或者是return false/true
else
return ;//可勾选
}
5、table展开功能
<h5>远程工具列表:</h5>
<el-table ref="assistanceTool" :data="toolsOpt" row-key="name" :expand-row-keys="expands">
<el-table-column type="expand">
<template slot-scope="props">
<div class="instructions">{{ props.row.instructions }}</div>
</template>
</el-table-column>
<el-table-column prop="name" label="名称"></el-table-column>
<el-table-column prop="copyright" label="版权" width=""></el-table-column>
<el-table-column prop="version" label="版本" width=""></el-table-column>
<el-table-column prop="downurl" label="下载链接"></el-table-column>
<el-table-column label="介绍" width="">
<template slot-scope="scope">
<el-button @click="view(scope.row)" type="text" size="small">查看</el-button>
</template>
</el-table-column>
</el-table>
//1、首先需要:row-key="name" :expand-row-keys="expands"
//2、点击查看的方法:如果expands没有就把name push进去,下面这种是一次只能展开一个,点击别的,关闭之前的
view(row){
if (this.expands.indexOf(row.name) < ) {
this.expands = []
this.expands.push(row.name);
} else {
this.expands = []
}
},

6、表格筛选功能
//1、首先需要加上下面这些,prop是必须加的,否则不生效
<el-table-column
prop="category"
label="类目"
:filters="categoryFilter"
:filter-method="filterType"
filter-placement="bottom-end">
</el-table-column> //2、定义categoryFilter数组存filter字段,然后在获取数据的时候去遍历赋值
fetchData(){
getScriptListApi().then(res => {
if(res.status === ){
this.scriptData = res.data
res.data.forEach(item => {
this.initFilter(this.typeFilter,item.type)
this.initFilter(this.categoryFilter,item.category)
})
}
})
}, //3、加上下面2个公共方法即可
initFilter(array,item){
let _obj = {
text:item,
value:item
}
if(JSON.stringify(array).indexOf(JSON.stringify(_obj)) === -){
array.push(_obj)
}
},
filterType(value,row,column){
const property = column['property'];
return row[property] === value;
},
另外还有一个 filter-change 方法(用@filter-change绑定),要在table根节点上设,而不是el-table-column节点的方法,那是个全局的方法,只要你的表头有filter变化了,就会触发
Element table使用技巧详解的更多相关文章
- 前端html、CSS快速编写代码插件-Emmet使用方法技巧详解
前端html.CSS快速编写代码插件-Emmet使用方法技巧详解 Emmet的前身是大名鼎鼎的Zen coding,如果你从事Web前端开发的话,对该插件一定不会陌生.它使用仿CSS选择器的语法来 ...
- Bootstrap Table使用方法详解
http://www.jb51.net/article/89573.htm bootstrap-table使用总结 bootstrap-table是在bootstrap-table的基础上写出来的,专 ...
- MySQL SQL查询优化技巧详解
MySQL SQL查询优化技巧详解 本文总结了30个mysql千万级大数据SQL查询优化技巧,特别适合大数据里的MYSQL使用. 1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 ...
- ORACLE中RECORD、VARRAY、TABLE的使用详解(转)
原文地址:ORACLE中RECORD.VARRAY.TABLE的使用详解
- 3dmax联机分布式渲染方法技巧详解
3dmax联机分布式渲染方法技巧详解 \测试环境:win7系统 3DMAX2009 Vray2.0 .首先要保证你的两台电脑能在局域网里互相访问如图: 其他电脑上也一样都能打开对方的电脑! 步! ...
- 训练技巧详解【含有部分代码】Bag of Tricks for Image Classification with Convolutional Neural Networks
训练技巧详解[含有部分代码]Bag of Tricks for Image Classification with Convolutional Neural Networks 置顶 2018-12-1 ...
- MyEclipse使用技巧详解
MyEclipse使用技巧的掌握是和我们开发效率挂钩的,那么如何掌握MyEclipse使用技巧呢?这里向你详细介绍了几种使用技巧的操作方法. 在了解MyEclipse使用技巧之前我们来看看MyEcli ...
- ping命令技巧详解 windows下ping命令知识大全
windows ping命令对于多数电脑爱好者都不会陌生,通过ping ip可以知道网络是否畅通或者网络传输质量如何等,是网络技术人员常用的检测网络命令,多数朋友对ping命令知道的并不多,接下来本文 ...
- 常见26个jquery使用技巧详解(比如禁止右键点击、隐藏文本框文字等)
来自:http://www.xueit.com/js/show-6015-1.aspx 本文列出jquery一些应用小技巧,比如有禁止右键点击.隐藏搜索文本框文字.在新窗口中打开链接.检测浏览器. ...
随机推荐
- poj-2528线段树练习
title: poj-2528线段树练习 date: 2018-10-13 13:45:09 tags: acm 刷题 categories: ACM-线段树 概述 这道题坑了我好久啊啊啊啊,,,, ...
- Java中面向对象的理解
按照惯例,先做一个简单的介绍,现在开始学习 Thinging in Java 4 ,一边看,一边记录,我都不想给自己设定时间安排了,毕竟很少实现过.所以就这样吧!不定期的更新,我都会放到博客中的. 所 ...
- java面试 关键字
1. final关键字有哪些用法? 修饰类.方法和变量. (1) final变量是只读的,不允许改变其引用,与static共用可声明常量.JVM会对final变量进行优化,比如常量折叠. (2) fi ...
- codevs 5971 打击犯罪
5971 打击犯罪 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description 某个地区有n(n<=1000)个犯罪团伙,当地警方按照他们 ...
- 【取对数】【哈希】Petrozavodsk Winter Training Camp 2018 Day 1: Jagiellonian U Contest, Tuesday, January 30, 2018 Problem J. Bobby Tables
题意:给你一个大整数X的素因子分解形式,每个因子不超过m.问你能否找到两个数n,k,k<=n<=m,使得C(n,k)=X. 不妨取对数,把乘法转换成加法.枚举n,然后去找最大的k(< ...
- BZOJ 4403: 序列统计 数学 lucas
4403: 序列统计 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=4403 Description 给定三个正整数N.L和R,统计长度在 ...
- PHP self与static区别
this,static和self. self和this还是很好区分的,可是self和static就很糊涂了,两者都能调用静态的方法和属性,看似使用上没有什么太大的分别,但是实际上分别很大,先来看下面这 ...
- [Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/5093566007214080
相信如果用谷歌浏览器做移动端页面的时候 用touch事件的时候应该遇到过这个东东吧 documet.addEventListener("touchstart",function() ...
- HOWTO: Get the command line of a process(转)
How would you get the command line of a process? Some people have suggested that you use remote thre ...
- 5V and 3V Level Translators
http://www.daycounter.com/Circuits/Level-Translators/Level-Translators.phtml Interfacing 5V and 3V l ...