Skip to content

Commit 969349f

Browse files
committed
【feature】
Doc of new `beforeStartCellEditing` callback method for cell editing function
1 parent bc04aed commit 969349f

File tree

4 files changed

+45
-6
lines changed

4 files changed

+45
-6
lines changed

examples/src/docs/en/ve-table/api/db.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,13 @@ export const db = {
961961
// 单元格编辑配置
962962
editOption: {
963963
data: [
964+
{
965+
param: "beforeStartCellEditing",
966+
desc: `before start editing cell callback method.<code>row</code>Current row data,<code>column</code>Current column,<code>cellValue</code>Current cell value.If false is returned,Will prevent the cell from starting the editing state`,
967+
type: `<code>Function({ row, column,cellValue })</code>`,
968+
optionalVal: "-",
969+
default: "-",
970+
},
964971
{
965972
param: "beforeCellValueChange",
966973
desc: `before cell value change callback method. <code>row</code>Current row data,<code>column</code>Current column,<code>changeValue</code>change value. If false is returned, cell editing will be blocked, the cell will back to the state before editing`,

examples/src/docs/en/ve-table/cell-edit/base.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Trying to change the value of the 'Number' column to a non number
44

5-
:::demo 1.After the cell stops editing, the `beforeCellValueChange` callback is triggered first. If false is returned, the editing will be blocked and the cell will be restored to the state before editing. If the editing is successful, the `afterCellValueChange` method will be triggered<br>2.You can use beforecellvaluechange to verify the contents of cell editing
5+
:::demo 1.Before a cell enters the editing state, the `beforeStartCellEditing` callback is first triggered. If false is returned, it will prevent the cell from entering the editing state<br>2.After the cell stops editing, the `beforeCellValueChange` callback is triggered first. If false is returned, the editing will be blocked and the cell will be restored to the state before editing. If the editing is successful, the `afterCellValueChange` method will be triggered<br>3.You can use beforecellvaluechange to verify the contents of cell editing
66

77
```html
88
<template>
@@ -29,6 +29,18 @@ Trying to change the value of the 'Number' column to a non number
2929
},
3030
// edit option
3131
editOption: {
32+
beforeStartCellEditing: ({ row, column, cellValue }) => {
33+
console.log("beforeStartCellEditing");
34+
console.log("row::", row);
35+
console.log("column::", column);
36+
console.log("cellValue::", cellValue);
37+
console.log("---");
38+
39+
if (row.rowKey === 0 && column.field === "name") {
40+
alert("You can't edit this cell.");
41+
return false;
42+
}
43+
},
3244
beforeCellValueChange: ({ row, column, changeValue }) => {
3345
console.log("beforeCellValueChange");
3446
console.log("row::", row);
@@ -98,7 +110,7 @@ Trying to change the value of the 'Number' column to a non number
98110
// table data
99111
tableData: [
100112
{
101-
name: "John",
113+
name: "You can't edit",
102114
date: "1900-05-20",
103115
number: "32",
104116
address: "No.1 Century Avenue, Shanghai",

examples/src/docs/zh/ve-table/api/db.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,13 @@ export const db = {
954954
// 单元格编辑配置
955955
editOption: {
956956
data: [
957+
{
958+
param: "beforeStartCellEditing",
959+
desc: `单元格进入编辑状态前的回调方法。<code>row</code>当前行数据,<code>column</code>当前列信息,<code>cellValue</code>当前单元格的值。如果返回false,将则会阻止单元格进入编辑状态`,
960+
type: `<code>Function({ row, column,cellValue })</code>`,
961+
optionalVal: "-",
962+
default: "-",
963+
},
957964
{
958965
param: "beforeCellValueChange",
959966
desc: `单元格内容改变前的回调方法。<code>row</code>当前行数据,<code>column</code>当前列信息,<code>changeValue</code>单元格改变的值。如果返回false,将会阻止编辑,单元格还原为编辑前状态`,
@@ -970,7 +977,7 @@ export const db = {
970977
},
971978
{
972979
param: "cellValueChange",
973-
desc: `将被移除`,
980+
desc: `即将废弃的方法`,
974981
type: `<code>Function({ row, column })</code>`,
975982
optionalVal: "-",
976983
default: "-",

examples/src/docs/zh/ve-table/cell-edit/base.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
:::anchor 基本用法
22

3-
尝试将 “Number”列的值改为非数字
3+
1、尝试将 “Number”列的值改为非数字<br>
4+
2、尝试修改第一行第一列
45

5-
:::demo 1、单元格停止编辑后首先触发`beforeCellValueChange`回调,如果返回 false,则会阻止编辑,单元格还原为编辑前状态。编辑成功将触发`afterCellValueChange`方法<br>2、你可以利用`beforeCellValueChange`做编辑校验功能
6+
:::demo 1、单元格进入编辑状态前首先触发`beforeStartCellEditing`回调,如果返回 false,则会阻止进入编辑状态。<br>2、单元格停止编辑后首先触发`beforeCellValueChange`回调,如果返回 false,则会阻止编辑,单元格还原为编辑前状态。编辑成功将触发`afterCellValueChange`方法<br>3、你可以利用`beforeCellValueChange`做编辑校验功能<br>
67

78
```html
89
<template>
@@ -29,6 +30,18 @@
2930
},
3031
// edit option 可控单元格编辑
3132
editOption: {
33+
beforeStartCellEditing: ({ row, column, cellValue }) => {
34+
console.log("beforeStartCellEditing");
35+
console.log("row::", row);
36+
console.log("column::", column);
37+
console.log("cellValue::", cellValue);
38+
console.log("---");
39+
40+
if (row.rowKey === 0 && column.field === "name") {
41+
alert("You can't edit this cell.");
42+
return false;
43+
}
44+
},
3245
beforeCellValueChange: ({ row, column, changeValue }) => {
3346
console.log("beforeCellValueChange");
3447
console.log("row::", row);
@@ -98,7 +111,7 @@
98111
// table data
99112
tableData: [
100113
{
101-
name: "John",
114+
name: "You can't edit",
102115
date: "1900-05-20",
103116
number: "32",
104117
address: "No.1 Century Avenue, Shanghai",

0 commit comments

Comments
 (0)