BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
@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;
}
}
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.
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
Not work validation in last release 20.4.0.50
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.
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
I adhere to the general design for the entire application. Made adding an object to the dialog.
Hi Kavit,
We are quite unclear of your query. So please share the detailed explanation of the issue faced / query to proceed further.
the style (theme) of the application must be common for all windows, all elements, messages must be the same.
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:-
Demo link : https://blazor.syncfusion.com/demos/tree-grid/dialog-editing?theme=fluent
Please provide us more information for better understanding of your query.
Regards,
Shek
This validation: https://blazor.syncfusion.com/demos/tree-grid/dialog-editing?theme=fluent&_gl=1*1eesphd*_ga*MTYzNTk3MDU2OC4xNjc1NjA1OTg4*_ga_WC4JKKPHH0*MTY3NzE1MDkyMy4xNi4wLjE2NzcxNTA5MjUuMC4wLjA.&_ga=2.244631619.734533381.1677150924-1635970568.1675605988 not using in ColumnTemplate. I using ColumnTemplete for add and edit record in grid or treegreed.
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
No. Validation only inside model with attribution [Required(ErrorMessage="")].....
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.
Ok. Will wait.
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.