- Home
- Forum
- Angular - EJ 2
- Restrict new task falls between start and end date of the project
Restrict new task falls between start and end date of the project
Hi there, is there a feature or validation while adding a new task to stay in between a date range ? for example I have project start date as 1st May 21 and end date as 30th May 21, I want to add a new task that should fall between the start and end date, is there a validation for date controls I can add in the 'New Task Dialog' ?
SIGN IN To post a reply.
4 Replies
1 reply marked as answer
PP
Pooja Priya Krishna Moorthy
Syncfusion Team
July 15, 2021 08:43 AM UTC
Hi Praveen,
Thanks for contacting Syncfusion support.
Yes, we validate internally while adding new tasks.
By default, we set the minimum start date of a record while adding new task and duration as one by default.
We can also modify these dates using add dialog of Gantt control.
Please get back to us if you need more information on this.
Regards,
Pooja K.
PK
Praveen Kumar Padma
July 15, 2021 01:17 PM UTC
Hi Pooja,
Thank you for getting back on this, is there a way to only enable only selected project dates(startDate to endDate) ? so that user knows task needs to be added between those dates, could you please provide more information on this or if you can direct me in correct direction that will be great?
MS
Monisha Sivanthilingam
Syncfusion Team
July 16, 2021 12:28 PM UTC
Hi Praveen,
We can achieve your query by making use of the openAddDialog requestType in the actionComplete event. By setting the min and max values for the startDate and endDate fields, we can restrict the range of dates available according to your requirements. The following code snippets demonstrate the solution.
App.component.html
|
<ejs-gantt id="ganttDefault" height="430px" [dataSource]="data" [taskFields]="taskSettings"
[columns]="columns"
[labelSettings]="labelSettings" [treeColumnIndex]="1"
height="450px" [allowSelection]="true" dateFormat="MMM dd, y"
[projectStartDate]="projectStartDate" [projectEndDate]="projectEndDate"
[highlightWeekends]="true" [editSettings]="editSettings"
[toolbar]="toolbar" [resourceFields] = "resourceFields"
[resources]="resources" (actionComplete)="actionComplete($event)">
</ejs-gantt>
|
App.component.ts
|
public actionComplete(args: any){
if(args.requestType == "openAddDialog"){
var startDate = (document.getElementById("ganttDefaultStartDate") as any).ej2_instances[0];
startDate.min = new Date(this.projectStartDate);
startDate.max = new Date(this.projectEndDate);
var endDate = (document.getElementById("ganttDefaultEndDate") as any).ej2_instances[0];
endDate.min = new Date(this.projectStartDate);
endDate.max = new Date(this.projectEndDate);
}
}
|
We have prepared a sample for your reference.
Please contact us if you require any further assistance.
Regards,
Monisha.
Marked as answer
Monisha,
thank you for the reply, code and sample, it works like charm!
SIGN IN To post a reply.
- 4 Replies
- 3 Participants
- Marked answer
-
PK Praveen Kumar Padma
- Jul 14, 2021 05:33 PM UTC
- Jul 16, 2021 01:45 PM UTC