Validator Component

I have written a custom validator component for my templated grid form, I pass ValidatorTemplateContext to this component, inside the component I do various validation checks. 

I cant figure out how to check the action of the form inside the validator component , for example I would like to do different check based off whether I am updating a record or adding it.

Thanks


1 Reply

RN Rahul Narayanasamy Syncfusion Team April 12, 2022 02:43 PM UTC

Hi Barry,


Greetings from Syncfusion.


We suspect that you have implemented the Custom Validator component on your own like this documentation. You want to know whether the particular action is Add or Edit. If yes, then we suggest you to find the corresponding action that is added/edited by using the OnActionBegin event. Find the below code snippets for your reference.


Reference:

https://blazor.syncfusion.com/documentation/datagrid/events#onactionbegin


 

<SfGrid DataSource="EmployeeList" AllowPaging="true" Toolbar="toolbar">

    <GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true"></GridEditSettings>

    <GridEvents OnActionBegin="ActionBeginHandler" TValue="EmployeeDetails"></GridEvents>

    <GridColumns>

        . .

    </GridColumns>

</SfGrid>

 

@code

{

    . ..

    string EditType { get; set; }

    public void ActionBeginHandler(ActionEventArgs<EmployeeDetails> args)

    {

        if (args.RequestType.Equals(Syncfusion.Blazor.Grids.Action.Add))

        {

            EditType = "Add";

        } else if (args.RequestType.Equals(Syncfusion.Blazor.Grids.Action.BeginEdit))

        {

            EditType = "Edit";

        }

    }

 

    . . .

}


If it is not your requirement or if we misunderstood your requirement, then could you please share more details about your requirement.


Regards,

Rahul


Loader.
Up arrow icon