client side validation on gantt dialog box

When adding or editing a task from gantt dialog box, how to apply client side validation to some required fields. Lets say taskName is required (the field Nom in french in the screenshot). If the field is empty and the user clicks the save button, then a message "Required field" is displayed and the dialog stays opened

Attachment: validation_1c03a28e.zip

3 Replies 1 reply marked as answer

PP Pooja Priya Krishna Moorthy Syncfusion Team August 20, 2020 10:41 AM UTC

Hi Harifenitra, 
Currently we don’t have validation support for add/edit dialog. We have already logged feature for this. The status can be tracked from below feedback link. 
As we have already lined up some major features, we could not start its implementation immediately. Please cast your vote to make it count. We will prioritize the features for every release based on demands. 
At present, we have disabled the save button of add/edit dialog when the task name field is empty using actioncomplete event with requestType openAdddialog and openEditDialog respectively. Please find the below code example. 


public actionComplete(args: any) : void { 
   var ganttObj = this.ganttObj; 
   if (args.requestType == "openEditDialog" || args.requestType == "openAddDialog" ) { 
   var textBox = document.getElementById('ganttDefaultTaskName').ej2_instances[0]; 
       textBox.input = function(args){ 
        var dialog = ganttObj.element.querySelectorAll("#" + ganttObj.controlId + "_dialog"); 
         var dialogFooter = dialog[0].querySelectorAll(".e-footer-content"); 
         if (args.value == "") 
           dialogFooter[dialogFooter.length - 1].children[0].disabled = true; 
         else 
          dialogFooter[dialogFooter.length - 1].children[0].disabled = false; 
     } 
  } 
} 
In the provided sample, whenever the value in the task name field changes, input event of textbox control gets triggered. Using this event we have disabled the save button. 


Regards, 
Pooja K.

Marked as answer

HP Harifenitra Pacôme August 21, 2020 06:54 AM UTC

Thanks for Your reply, it has helped us enormously.


PP Pooja Priya Krishna Moorthy Syncfusion Team August 21, 2020 06:59 AM UTC

Hi Harifenitra, 
Most welcome. 
We are happy to hear, that your requirement has been fulfilled. 
Please get back to us if you have any other queries. 

Regards, 
Pooja K. 


Loader.
Up arrow icon