简体   繁体   English

农业网格单元渲染器单元验证

[英]ag-grid cell renderer cell validation

I tried for cell validations in the ag-grid cell renderer. 我尝试在ag-grid单元渲染器中进行单元验证。

I am not able to achieve this. 我无法实现这一目标。

The following is my code sample. 以下是我的代码示例。

columns = [
                    { headerName: "Sequence", field: "domainDetailSeq", cellRendererFramework: GridInputComponent },
                    { headerName: "Detail Id", field: "domainDetailId", cellRendererFramework: GridInputComponent }
                ]

Here is the cell renderer component. 这是单元格渲染器组件。

import { Component } from "@angular/core";
import { ICellRendererAngularComp } from "ag-grid-angular/main";

@Component({
    selector: 'child-cell',
    template: `<div fxLayout="row" class="grid-actions">
           <input required type="text" (blur)="invokeParentMethod($event)" [value]="params.value" [hidden]="params.data.createdBy && params.colDef.field==='domainDetailId'">
            <span [hidden]="!params.data.createdBy" *ngIf="params.colDef.field==='domainDetailId'">{{params.value}}</span>
        </div>`
})
export class GridInputComponent implements ICellRendererAngularComp {
    public params: any;

    agInit(params: any): void {
        this.params = params;
    }

    public invokeParentMethod($event: MouseEvent, mode: string) {
        $event.preventDefault();
        this.params.context.componentParent.update(this.params, $event);
    }
}

I have a submit button on the main page, when clicked, I need to perform validations like required and show the required messages there. 我在主页上有一个提交按钮,单击后,我需要执行所需的验证并在此处显示所需消息。

Any suggestions will be appreciable. 任何建议将是可取的。

您可以在网格字段中使用cellClassRules属性来实现:

configuration.cellClassRules:{'required-class':(params)=>{return <condition>}}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM