Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于Table可编辑行的几个疑问 #267

Closed
tky753 opened this issue Feb 11, 2021 · 5 comments
Closed

关于Table可编辑行的几个疑问 #267

tky753 opened this issue Feb 11, 2021 · 5 comments

Comments

@tky753
Copy link

tky753 commented Feb 11, 2021

用的thin版本,不知道在这里发帖是否合适

  1. column设置了editRule 后,单元格input控件每次输入字符都会触发editRule,是否有必要?
  2. column设置了editRule 后,编辑行状态下,调用 record.onEdit?.(false, true) 同一单元格的editRule会触发两次,而且不知道为什么第一次触发时值为空第二次正确,因为我editRule加了个验证空的话会返回'XX不能为空',所以onEdit会返回false,以第一次触发为准。(不过在非thin版本虽然也触发两次,但第一次触发值不为空)
  3. record.onEdit?.(false, true) 后,编辑控件值会写入record,那在此之前如何获取到控件的当前值?
@anncwb
Copy link
Collaborator

anncwb commented Feb 17, 2021

  1. 每次输入类似于change事件触发表单校验。这在正常的表单校验也是正常的。
    2,3. 可以提供下具体代码?

@tky753
Copy link
Author

tky753 commented Feb 18, 2021

@anncwb
第二个问题:
非thin项目下的src\views\demo\page\form\high\PersonTable.vue文件中的大约27行处,加上

      editRule: async (text) => {
        console.log('成员姓名:'+text);
        if (!text) {
          return '不能为空';
        }
        return '';
      },

image
对应界面(页面/表单页/高级表单)上,成员管理随便一条点编辑,再点保存:
image
控制台显示
image
第三个问题:
也在非thin项目下的src\views\demo\page\form\high\PersonTable.vue文件中的大约96行处,加一句console.log(JSON.stringify(record));
image
对应界面(页面/表单页/高级表单)上,成员管理增加一条点保存
image
控制台会输出
image
可以看出,在调用onEdit前record里没有数据,所以想知道如何在此之前获取到控件值
PS:这里还有一个问题,点保存没有在绑定数据源增加一行,,考虑到这是demo,可能也没什么关系

@anncwb anncwb closed this as completed in 4f8e1c1 Feb 19, 2021
@anncwb
Copy link
Collaborator

anncwb commented Feb 19, 2021

第二个问题已经修复,第三问题PersonTable最新的代码,增加了edit-change事件,可以在值改变后触发,然后保存到变量,这样就可以在保存前拿到

@tky753
Copy link
Author

tky753 commented Feb 21, 2021

@anncwb 求教 第二个问题怎么修复的,我thin那边的项目还是会触发两次,第一次原始值,貌似是EditableCell初始化了两次,不明白啊啊啊

@tky753
Copy link
Author

tky753 commented Feb 22, 2021

@anncwb 终于发现问题所在了,如果column加上 fixed: 'left',就会触发第二个问题:
EditableCell初始化了两次,调用record.onEdit?.(false, true);时触发两次editRule,且第一次传入参数如果新行则为空,修改行则为修改前的值。
image

@github-actions github-actions bot locked and limited conversation to collaborators Sep 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants