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

Min/Max date for datepicker

Hello,

I want to restrict date selections to some range in Gantt. e.g. Start date and end date should be between a defined range. It will be fine if it can be set during Gantt initialization or at the time of editing the date fields.

How to set min/max dates for date picker at the time of editing the Gantt?

1 Reply

SR Suriyaprasanth Ravikumar Syncfusion Team January 2, 2017 12:31 PM UTC

Hi Kuntal, 
Thanks for contacting Syncfusion support. 
We can set the maximum and minimum date to start date and end date column in Gantt by add editParams property to these columns. 
We have added minDate and maxDate value in editparams  of  start date and end date columns in “Load” client side event. 
Please find the code snippet below. 
@(Html.EJ().Gantt("GanttContainer") 
  //.. 
.ClientSideEvents(eve => 
                                      { 
                                          eve.Load("load"); 
                                      }) 
  //.. 
) 
 
 
function load() { 
                var column = this.getColumns(); 
                for (var index = 0; index < column.length; index++) { 
                    if (column[index].editType === "datepicker") { 
                        column[index].editParams = { minDate: "02/23/2014", maxDate: "03/30/2014" }; 
                    }  
                   } 
              } 
 
We have also prepared the sample for your reference, please find the sample from below location.  
  
Disclaimer: We have removed bin and obj folder in the given sample for some security reasons, 
we must include Syncfusion.EJ and Syncfusion.EJ.MVC dlls to render the Gantt control which is available in Essential studio installed location. 
Please let us know if you require further assistance on this. 
 
Thanks, 
Suriyaprasanth R. 


Loader.
Up arrow icon