如何为农业网格行编辑实施验证规则 [英] How to implement validation rules for ag-grid row edit

查看:115
本文介绍了如何为农业网格行编辑实施验证规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有使用普通Angular Reactive Forms进行内联编辑的html表,其中包括许多验证规则:

I currently have html table with inline editing that uses plain Angular Reactive Forms, including a lot of validation rules:

var formArray = new FormArray(this.items.map(createItemFormGroup));

createItemFormGroup(item){
   return new FormGroup({
        prop1: new FormControl(item.prop1, [Validators.required, Validators.min(1)])
        prop2:...
   })
}

是否有如何将ag-grid与Angular验证集成的示例?要求是,我需要突出显示无效的单元格值。我不一定需要使用FormGroup ...

Is there any example of how to integrate ag-grid with Angular validations? The requirement is, that I need to highlight invalid cell values. I don't necessarily need to use FormGroup…

我可能会使用全行编辑,所以一种方法是仅为行创建FormGroup,即编辑。...

I will probably use full row editing, so one way to go would be to create FormGroup only for row, that is being edited....

推荐答案

有两种可能的验证处理方式:

There are two ways of possible validation handling:

首先:通过 ValueSetter 函数

First: via ValueSetter function

第二:通过自定义 cellEditor 组件

Second: via custom cellEditor component

示例一个

示例二

异步验证

扩展的验证

这篇关于如何为农业网格行编辑实施验证规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆