EditRow.ts

vue+element-ui+slot-scope原生实现可编辑表格


interface NoParamConstructor<T> {
new(): T;
} export default class EditRow<T> {
origin: T = null
copy: T = null
is_edit: boolean = false
ctor: NoParamConstructor<T>; constructor(ctor: NoParamConstructor<T>, origin: T) {
this.ctor = ctor
this.origin = origin
this.show_edit = this.show_edit.bind(this)
this.save = this.save.bind(this)
}
show_edit() {
this.copy = Object.assign(new this.ctor(), this.origin)
this.is_edit = true
}
save() {
this.origin = this.copy
this.is_edit = false
}
}

vue file


<template>
<el-row>
<el-table :data="rows" size="mini">
<el-table-column label="name">
<template slot-scope="scope">
<template v-if="scope.row.is_edit">
<input v-model="scope.row.copy.name" />
<el-button size="mini" @click="scope.row.save">save</el-button>
<el-button size="mini" @click="scope.row.is_edit = false">cancel</el-button>
</template>
<template v-else>
<span @click="scope.row.show_edit">{{ scope.row.origin.name }}</span>
</template>
</template>
</el-table-column>
</el-table>
</el-row>
</template> <script>
import EditRow from './EditRow.ts' class entity {
constructor() {
this.name = '123'
}
} const rows = [
new EditRow(entity, new entity())
] export default {
data() {
return {
rows
}
}
}
</script>

原文地址:https://segmentfault.com/a/1190000012471593

element-ui table 行内编辑的更多相关文章

  1. JS组件系列——BootstrapTable 行内编辑解决方案:x-editable

    前言:之前介绍bootstrapTable组件的时候有提到它的行内编辑功能,只不过为了展示功能,将此一笔带过了,罪过罪过!最近项目里面还是打算将行内编辑用起来,于是再次研究了下x-editable组件 ...

  2. [转]JS组件系列——BootstrapTable 行内编辑解决方案:x-editable

    本文转自:http://www.cnblogs.com/landeanfen/p/5821192.html 阅读目录 一.x-editable组件介绍 二.bootstrapTable行内编辑初始方案 ...

  3. js插件---JS表格组件BootstrapTable行内编辑解决方案x-editable

    js插件---JS表格组件BootstrapTable行内编辑解决方案x-editable 一.总结 一句话总结:bootstrap能够做为最火的框架,绝对不仅仅只有我看到的位置,它应该还有很多位置可 ...

  4. bootstrap-editable实现bootstrap-table行内编辑

    bootstrap-editable行内编辑效果如下: 需要引入插件 列初始化代码,为可编辑的列添加editable属性: columns = [ { title: '文件名', field: 'Na ...

  5. BootStrap行内编辑

    Bootstrap行内编辑,这里下载了一个X-Editable的插件,在Nuget里面就可以搜到. 引用的js和css大致如下: @*.Jquery组件引用*@ <script src=&quo ...

  6. datatables表格行内编辑的实现

    Datatables是一款jquery表格插件,它是一个高度灵活的工具,灵活就意味着很多功能需要自己去实现,比如说行内编辑功能. Datatables自己是没有行内编辑功能的,最简单的是通过modal ...

  7. bootstrap editable 行内编辑

    除了那些bootstrap/bootstrap table的js , css之外,要额外添加editable的文件: <link href="../assets/css/bootstr ...

  8. Django项目:CRM(客户关系管理系统)--69--59PerfectCRM实现king_admin行内编辑

    #base_admin.py # ————————24PerfectCRM实现King_admin自定义操作数据———————— from django.shortcuts import render ...

  9. ASP.NET Aries 入门开发教程6:列表数据表格的格式化处理及行内编辑

    前言: 为了赶进度,周末也写文了! 前几篇讲完查询框和工具栏,这节讲表格数据相关的操作. 先看一下列表: 接下来我们有很多事情可以做. 1:格式化 - 键值的翻译 对于“启用”列,已经配置了格式化 # ...

随机推荐

  1. 分组后取每组内排名的Top N的SQL语句

    给个MySQL例子参考 -----查询每门课程的前2名成绩 CREATE   TABLE   StudentGrade( stuId   CHAR(4),         --学号 subId   I ...

  2. HD-ACM算法专攻系列(7)——Text Reverse

    问题描述: 源码: /**/ #include"iostream" #include"string" using namespace std; void Pri ...

  3. MyBatis数据持久化(八)sql复用

    在mybatis中,我们可以將sql语句中公共的部分提取出来,然后需要该段sql的地方通过include标签引入即可,这样可以达到sql语句复用的目的. 例如我们有两条相似的查询语句: <sel ...

  4. 你不知道的JavaScript(八)逻辑运算

    JS的逻辑运算结果和其他一些强类型语言差别比较大,也比较容易让人产生困惑,看下面的例子: <script type="text/javascript"> var a = ...

  5. 51nod 2020 排序相减(暴力解法)

    题目: 代码: #include <bits\stdc++.h> using namespace std; int trim(int x){ ]; ;i < ; i++){ a[i] ...

  6. ActiveMQ学习笔记(7)----ActiveMQ支持的传输协议

    1. 连接到ActiveMQ Connector: Active提供的,用来实现连接通讯的功能,包括:client-to-broker,broker-to-broker.ActiveMQ允许客户端使用 ...

  7. socket网络编程登录实现及多客户端和服务端的数据交互

    一.TCP/IP 客户端 package com.demo.entity; import java.io.Serializable; public class UserInfo implements ...

  8. (转)JVM内存管理-----堆内存

    来源:http://blog.csdn.net/yu422560654/article/details/7952613 Heap堆内存理解 一个JVM实例只有一个堆内存,堆内存的大小是可以调节的.类加 ...

  9. org.apache.ibatis.binding.BindingException: Parameter ‘brOrderNo’ not found. Available parameters ar

    最近使用 mybatis 写项目的时候遇到报错:org.apache.ibatis.binding.BindingException: Parameter 'brOrderNo' not found. ...

  10. unity 调用 .dll 或 .so时遇到的问题

    1.32位的 .dll 无法在64位的unity编辑器下运行. System.DllNotFoundException: xxx  , 64位的程序运行32位的dll是会报这种错 2.Failed t ...