element-ui table 行内编辑
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 行内编辑的更多相关文章
- JS组件系列——BootstrapTable 行内编辑解决方案:x-editable
前言:之前介绍bootstrapTable组件的时候有提到它的行内编辑功能,只不过为了展示功能,将此一笔带过了,罪过罪过!最近项目里面还是打算将行内编辑用起来,于是再次研究了下x-editable组件 ...
- [转]JS组件系列——BootstrapTable 行内编辑解决方案:x-editable
本文转自:http://www.cnblogs.com/landeanfen/p/5821192.html 阅读目录 一.x-editable组件介绍 二.bootstrapTable行内编辑初始方案 ...
- js插件---JS表格组件BootstrapTable行内编辑解决方案x-editable
js插件---JS表格组件BootstrapTable行内编辑解决方案x-editable 一.总结 一句话总结:bootstrap能够做为最火的框架,绝对不仅仅只有我看到的位置,它应该还有很多位置可 ...
- bootstrap-editable实现bootstrap-table行内编辑
bootstrap-editable行内编辑效果如下: 需要引入插件 列初始化代码,为可编辑的列添加editable属性: columns = [ { title: '文件名', field: 'Na ...
- BootStrap行内编辑
Bootstrap行内编辑,这里下载了一个X-Editable的插件,在Nuget里面就可以搜到. 引用的js和css大致如下: @*.Jquery组件引用*@ <script src=&quo ...
- datatables表格行内编辑的实现
Datatables是一款jquery表格插件,它是一个高度灵活的工具,灵活就意味着很多功能需要自己去实现,比如说行内编辑功能. Datatables自己是没有行内编辑功能的,最简单的是通过modal ...
- bootstrap editable 行内编辑
除了那些bootstrap/bootstrap table的js , css之外,要额外添加editable的文件: <link href="../assets/css/bootstr ...
- Django项目:CRM(客户关系管理系统)--69--59PerfectCRM实现king_admin行内编辑
#base_admin.py # ————————24PerfectCRM实现King_admin自定义操作数据———————— from django.shortcuts import render ...
- ASP.NET Aries 入门开发教程6:列表数据表格的格式化处理及行内编辑
前言: 为了赶进度,周末也写文了! 前几篇讲完查询框和工具栏,这节讲表格数据相关的操作. 先看一下列表: 接下来我们有很多事情可以做. 1:格式化 - 键值的翻译 对于“启用”列,已经配置了格式化 # ...
随机推荐
- (转载) EditText初始不弹出软键盘,只有光标显示,点击再弹出
EditText初始不弹出软键盘,只有光标显示,点击再弹出 2013-06-08 10:13 21305人阅读 评论(5) 收藏 举报 分类: android基础(91) 版权声明:本文为博主原创 ...
- LeetCode 1. Two Sum (c++ stl map)
题目:https://leetcode.com/problems/two-sum/description/ stl map代码: class Solution { public: vector< ...
- 【算法】第二类斯特林数Stirling
第二类Stirling数实际上是集合的一个拆分,表示将n个不同的元素拆分成m个集合的方案数,记为 或者 . 第二类Stirling数的推导和第一类Stirling数类似,可以从定义出发考虑第n+1个元 ...
- python 时间差计算
import time import datetime datebg=input("date begin:") dateed=input("date end:" ...
- 我的Java历程_spring+springmvc+mybatils整合问题
作为一个初学框架的菜鸟,有时候遇到异常时真的不好判断问题的出处,因为一般框架不就是导jar包,配置文件嘛,对于一个新手来说要看懂错误出现的含义韩式有些难的,lz昨天整合spring+mybatils时 ...
- pycharm修改提示
- Node_进阶_6
Node进阶第六天 一.复习 cookie是在res中设置,req中读取的.第一次的访问没有cookie. cookie的存储大小有限,kv对儿.对用户可见,用户可以禁用.清除cookie.可以被篡改 ...
- Linux bash常用快捷键
移动光标 ctrl-a 光标移动到行首 ctrl-e 光标移动到行尾 ctrl+xx 在行首和光标位置直接切换 ctrl-b 光标左移一位 ctrl-f 光标右移一位 alt-b 光标左移一词 alt ...
- tar 命令man说明
TAR(1) User Commands TAR(1) NAME tar - manual page for tar 1.26 SYNOPSIS tar [OPTION...] [FILE]... D ...
- Linux 和 Windows 双系统时间同步问题 修改注册表
路径:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation 1:新建 >> DWORD(32 b ...