File tree Expand file tree Collapse file tree 6 files changed +37
-248
lines changed Expand file tree Collapse file tree 6 files changed +37
-248
lines changed Original file line number Diff line number Diff line change 11:::anchor 基础用法
22
3+ 右键表格区域查看效果
4+
35::: demo
46
57``` html
136138 methods: {},
137139 };
138140 </script >
139- <style >
140- #contextmenu-container {
141- display : flex ;
142- width : 300px ;
143- height : 300px ;
144- justify-content : center ;
145- align-items : center ;
146- background : #eee ;
147- border : 3px dashed #666 ;
148- border-radius : 8px ;
149- }
150- </style >
151141```
152142
153143:::
Original file line number Diff line number Diff line change 1+ :::anchor 右键菜单功能分类
2+
3+ 这些右键菜单功能你可以随意选择和组合
4+
5+ | 功能 | 类型 |
6+ | :----------- | :----------------- |
7+ | 分割线 | ` SEPARATOR ` |
8+ | 在上方插入行 | ` INSERT_ROW_ABOVE ` |
9+ | 在下方插入行 | ` INSERT_ROW_BELOW ` |
10+ | 移除该行 | ` REMOVE_ROW ` |
11+ | 隐藏该行 | ` HIDE_COLUMN ` |
Original file line number Diff line number Diff line change 2525 contextmenuBodyOption: {
2626 // callback for all options
2727 callback : ({ type, selection }) => {
28+ const { rowKey , colKey } = selection;
29+
30+ const rowIndex = this .tableData .findIndex ((x ) => x .rowKey === rowKey);
31+
32+ // custom empty row
33+ if (type === " custom-empty-row" ) {
34+ this .tableData = this .tableData .map ((rowData ) => {
35+ // empty current row
36+ if (rowData .rowKey === rowKey) {
37+ this .columns .forEach ((column ) => {
38+ rowData[column .field ] = " " ;
39+ });
40+ }
41+ return rowData;
42+ });
43+ }
44+
2845 console .log (" type::" , type);
2946 console .log (" selection::" , selection);
3047 },
4158 type: " SEPARATOR" ,
4259 },
4360 {
44- type: " REMOVE_ROW" ,
45- },
46- {
47- type: " SEPARATOR" ,
61+ type: " custom-empty-row" ,
62+ label: " empty row(custom)" ,
4863 },
4964 {
5065 type: " customType1" ,
167182 methods: {},
168183 };
169184 </script >
170- <style >
171- #contextmenu-container {
172- display : flex ;
173- width : 300px ;
174- height : 300px ;
175- justify-content : center ;
176- align-items : center ;
177- background : #eee ;
178- border : 3px dashed #666 ;
179- border-radius : 8px ;
180- }
181- </style >
182185```
183186
184187:::
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11::: tip
2- 1、待完善
2+ 1、有些操作可以通过右键菜单更方便的完成。比如单元格编辑功能,可以通过右键操作很方便的插入行或者移除行<br >
3+ 2、当然你也可以自定义右键菜单功能
34:::
Original file line number Diff line number Diff line change 22 <div >
33 <h2 >右键菜单</h2 >
44 <Explain />
5+ <ContextmenuTypes />
56 <Base />
67 <Custom />
78 </div >
89</template >
910<script >
1011import Explain from " ./explain.md" ;
12+ import ContextmenuTypes from " ./contextmenu-types.md" ;
1113import Base from " ./base.md" ;
1214import Custom from " ./custom.md" ;
1315
1416export default {
1517 name: " basic-main" ,
1618 components: {
1719 Explain,
20+ ContextmenuTypes,
1821 Base,
1922 Custom,
2023 },
You can’t perform that action at this time.
0 commit comments