We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

DataAnnotationsValidator not working.

@using Syncfusion.Blazor.TreeGrid

@using System.ComponentModel.DataAnnotations

@using Syncfusion.Blazor.Grids

Blazor. TreeGrid;


<SfTreeGrid @ref="TreeGrid" TValue="Tree" DataSource="GridData" IdMapping="TaskId" ParentIdMapping="ParentId" TreeColumnIndex="0"

            Toolbar="@(new List<string>() { "Add", "Edit", "Update", "Cancel", "Delete" })">

    <TreeGridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true"

                          Mode="Syncfusion. Blazor. TreeGrid. EditMode. Dialog">

        <Validator>

            <DataAnnotationsValidator></DataAnnotationsValidator>

        </Validator>

    </TreeGridEditSettings>

    <TreeGridColumns>

        <TreeGridColumn Field=@nameof(Tree.TaskId) HeaderText="Task ID" IsPrimaryKey="true" ValidationRules="new ValidationRules(){Required = true, Number = true}" Type="ColumnType.Number" TextAlign="TextAlign.Right" Width="120"></TreeGridColumn>

        <TreeGridColumn Field=@nameof(Tree.TaskName) HeaderText="TaskName" Width="120" Type="ColumnType.String"></TreeGridColumn>


        <TreeGridColumn Field=@nameof(Tree.Priority) HeaderText="Priority" Width="120" Type="ColumnType.String"></TreeGridColumn>

        <TreeGridColumn Field=@nameof(Tree.Duration) HeaderText="Duration" TextAlign="TextAlign.Right" Width="120" Type="ColumnType.Number" />

        <TreeGridColumn Field=@nameof(Tree.ParentId) HeaderText="ParentId" TextAlign="TextAlign.Right" Width="120" Type="ColumnType.Number" />

    </TreeGridColumns>

</SfTreeGrid>


@code{


    SfTreeGrid<Tree> TreeGrid { get; set; }

    private List<Tree> GridData;

    protected override void OnInitialized()

    {

        GridData = GetTree();

    }

    public class Tree

    {

        [Required(ErrorMessage = "Task ID should not be empty")]

        public int? TaskId { get; set; }


        [Required(ErrorMessage = "Task Name should not be empty")]

        public string TaskName { get; set; }

        [Required(ErrorMessage = "Priority should not be empty")]

        public string Priority { get; set; }


        public int? Duration { get; set; }

        public int? ParentId { get; set; }


    }

    public static List<Tree> list = new List<Tree>();

    public List<Tree> GetTree()

    {

        if (list.Count == 0)

        {

            list.Add(new Tree() { TaskId = 1, TaskName = "Parent Task 1", Duration = 10, ParentId = null, Priority = "Low" });

            list.Add(new Tree() { TaskId = 2, TaskName = "Child task 1", Duration = 4, ParentId = 1, Priority = "Low" });

            list.Add(new Tree() { TaskId = 3, TaskName = "Child Task 2", Duration = 5, ParentId = 1, Priority = "Critical" });

            list.Add(new Tree() { TaskId = 4, TaskName = "Parent Task 2", Duration = 6, ParentId = null, Priority = "Low" });

            list.Add(new Tree() { TaskId = 5, TaskName = "Child Task 5", Duration = 9, ParentId = 4, Priority = "High" });

        }

        return list;

    }

}


13 Replies

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team December 22, 2022 03:46 PM UTC

Hi Alexandr,


Greetings from Syncfusion Support.


We are able to replicate the problem from shared details.On further validation, we have considered the reported issue (“Validation message not shown properly”) as a bug. Thank you for taking the time to report this issue and helping us improve our product. At Syncfusion, we are committed to fixing all validated defects (subject to technological feasibility and Product Development Life Cycle) and will include the fix in our upcoming patch release which is expected to be rolled out on January 3rd week NuGet release, 2023. Until then we appreciate your patience.


You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link. 

https://www.syncfusion.com/feedback/40007/validation-message-not-shown-properly-while-using-dataannotation


Disclaimer:- You can view the feedback once it is move to validated state. To view the above feedback, kindly login into your account.


Disclaimer: Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.


Regards,

Farveen sulthana T



KA kavit February 15, 2023 10:18 AM UTC

Not work validation in last release 20.4.0.50



SM Shek Mohammed Asiq Abdul Jabbar Syncfusion Team February 16, 2023 11:10 AM UTC

Hi Kavit,


We deeply regret for the inconvenience caused.


Further validating the issue, we determined that it requires significant changes to provide support for Data Annotation. So, we have considered this “Need to provide DataAnnotation support” as uncertain feature and added this feature request to our database. It will be implemented in any of our upcoming release.

You can now track the status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link. 

https://www.syncfusion.com/feedback/40007/need-to-provide-dataannotation-support-for-blazor-tree-grid

Instead, you can use validation Rules for each column, as in the demo below.

Demo link : https://blazor.syncfusion.com/demos/tree-grid/dialog-editing?theme=fluent

Also, you can refer the API reference : https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.TreeGrid.TreeGridColumn.html#Syncfusion_Blazor_TreeGrid_TreeGridColumn_ValidationRules




KA kavit February 16, 2023 11:28 AM UTC

I adhere to the general design for the entire application. Made adding an object to the dialog.



SM Shek Mohammed Asiq Abdul Jabbar Syncfusion Team February 19, 2023 05:45 PM UTC

Hi Kavit,

We are quite unclear of your query. So please share the detailed explanation of the issue faced / query to proceed further.



KA kavit February 20, 2023 08:15 AM UTC

the style (theme) of the application must be common for all windows, all elements, messages must be the same.



SM Shek Mohammed Asiq Abdul Jabbar Syncfusion Team February 21, 2023 04:16 PM UTC

Hi Kavit,


Before proceeding this query, we need some more additional details to guide you in right way. So, we request to share us the following details:-


  1. Whether the validation message was not shown while implementing the following demo?

Demo link : https://blazor.syncfusion.com/demos/tree-grid/dialog-editing?theme=fluent

  1. The validation message does not depend on the themes, it shows based on the template(Validation rules) that we provide in tree grid columns. so, provide us complete tree grid code and explain in detail with Screenshot.
  2. Video demo that replicates the issue.


Please provide us more information for better understanding of your query.


Regards,

Shek




SM Shek Mohammed Asiq Abdul Jabbar Syncfusion Team February 24, 2023 01:56 PM UTC

Hi Kavit,


We appreciate your patience.


You can also apply validation rules for template column using ValidationRules property of the column as like the following code snippet :


<TreeGridColumn Field=@nameof(Tree.TaskName) HeaderText="TaskName" Width="120" Type="ColumnType.String" ValidationRules="@(new ValidationRules() { Required = true })">

            <Template>

                @{

                    var record = (context as Tree);

                    <div>

                        @record.TaskName

                    </div>

                }

            </Template>

        </TreeGridColumn>


Please get back to us if you are facing any difficulties on this.


Regards,

Shek



KA kavit February 24, 2023 02:29 PM UTC

No. Validation only inside model with attribution [Required(ErrorMessage="")].....



FS Farveen Sulthana Thameeztheen Basha Syncfusion Team February 28, 2023 02:32 PM UTC

Kavit,


As mentioned in previous update, currently we don’t have DataAnnotation support similar to this [Required(ErrorMessage="")] in TreeGrid.
So, we have considered this “Need to provide DataAnnotation support” as uncertain feature and added this feature request to our database. It will be implemented in any of our upcoming release.



KA kavit February 28, 2023 02:40 PM UTC

Ok. Will wait.



SM Shek Mohammed Asiq Abdul Jabbar Syncfusion Team March 1, 2023 02:10 PM UTC

Kavit,

Thanks for the update.

You can now track the status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link. 

https://www.syncfusion.com/feedback/40007/need-to-provide-dataannotation-support-for-blazor-tree-grid



Loader.
Live Chat Icon For mobile
Up arrow icon