Articles in this section
Category / Section

How to validate Gantt field while adding in ASP.NET MVC application?

1 min read

In Gantt control, it is possible to validate the fields provided by the user while adding or editing the data using actionBegin client side event. This event will be triggered with requestType argument as save before saving the data to Gantt, so at this point we can validate the fields with required condition.

The following code example explains the above scenario,

 
@(Html.EJ().Gantt("GanttSample")
//...
.ClientSideEvents(cl => { 
                       cl.ActionBegin("actionBegin");
                       cl.Load("load");                               
                   })
)
 
 

 

<script>
             function load(args) {
                 var columns = this.getColumns();
                 var column1 = {
                     field: "ActualDate",
                     headerText: "Actual Date",
                     mappingName: "ActualDate",
                     editType: "datepicker",
                 },
                 column2 = {
                     field: "EstimateDate",
                     headerText: "Estimate Date",
                     mappingName: "EstimateDate",
                     editType: "datepicker",
                 }
 
                 columns.splice(4, 0, column1, column2)
             }
 
             function actionBegin(args) {
 
                 if (args.requestType == "save") {
 
                     if (Date.parse(args.data.ActualDate) > Date.parse(args.data.EstimateDate)) {
 
                         args.cancel = true;
                         window.alert("Actual Date should not be greater than Estimated Date");
                     }
 
                 }
             }
    </script>   

 

 

The above example shows on how to validate the custom columns and alert the user if condition fails and cancel the add operation.

Sample link:

The simple sample to validate the Gantt fields while adding/ editing the data is available in the following link. Sample 

Conclusion

I hope you enjoyed learning about how to validate Gantt field while adding in ASP.NET MVC application.

You can refer to our .NET MVC Gantt feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our .NET MVC Gantt example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied