Hi Prasanth,
Query 1 : if I click "Add Above" on Task 2, There is a new record created with Task 3 but Task 2's Id is updated to 3 also. So I end up having 2 Tasks with same ID.
Solution : We have added a new task above to the selected row, using context menu also using public methods but we are not able to reproduce this issue. Can you please revert us by modifying the below attached sample based on the reported issue along with replication procedure?
Query 2 : Every time I add a new Task is there a way to pass these parameters (ProjectID & ID) back into Task records in Gantt control?
Solution: Do you want to send additional parameters to server method? If so, We can pass additional parameters to the server method using Ajax Post.
Code Snippet:
[cshtml]
<script type="text/javascript">
function ActionComplete(args) { //... var data = JSON.stringify({ 'Task': ganttRec, 'ProjectID': 8, //Set the Project ID 'ID': ganttRec.TaskId, }); $.ajax({ type: "POST", url: "/Gantt/Add", //Update is Server side method data: data, contentType: 'application/json', }); //... } </script>
[CS]
[HttpPost()] public void Add(TaskData Task, int ProjectID, int ID) { //... }
|
We have prepared a sample based on above queries, find the sample from below location.
Sample: http://www.syncfusion.com/downloads/support/forum/121423/ze/Gantt-1472000357
Please let us know if you need further assistance on this.
Regards,
Dinesh kumar.N
Hi Prasanthan,
Query 1 : Update event (which has correct data including Resource list) for the newly added task even though this task has never existed before then (some times before this step additionally update method is also called using Parent Task 1 object).
Solution : We have resolved this issue in our latest Syncfusion version 13.3.0.18, we have request you to update your version. You can download the latest version from below link.
Query 2 : Update event is fired using the Child Task view model, however I have noticed here there is an issue with Resource List.
Solution : The Item Collection which is from “ActionComplete” client side event includes only the defined fields in data source (in your sample, fields in ProjectTaskViewModel). If we want complete Resource collection of particular record then we can get it from “args.data.resourceInfo”, for more information find the following code snippet.
Code Snippet:
<script type="text/javascript"> function ActionComplete(args) { //args.data contains all datas of particular task.. var data = args.data.item; //Resource Details of the task. var resource = args.data.resourceInfo } </script> |
Query 3 : Resource length seems to be correct but however the resource list seems to be empty i.e. all the id values are set to 0.
Solution : We have analyzed your attached sample and noticed that you are defining the database ID field in ProjectTaskViewModel, but you never assign any value for the ID field while defining the Gantt datasource (in GanttData class).
We have prepared a sample with auto increment ID in SQL data table with above your requirements, find the sample from below location.
Sample : http://www.syncfusion.com/downloads/support/forum/121423/ze/MVCsampleSQL-2080498500
Please let us know, if you need further assistance on this.
Regards,
Dinesh kumar.N
Hi Prasanth,
Query 1 : However I still noticed that update method is called for parent task as well, though it's not a major issue.
Solution : It is default behavior of the Gantt, whenever we update the duration or progress field of any child task, the parent task of the corresponding child task should be updated as per the child task’s updated field values. For your clear understanding, instead of editing a task with edit dialog box, edit a particular cell by doing double click on them. If we change the duration field alone then the parent task will update because the changes will affect the parent task. If we change the “Task Name” field alone the parent task will not be affected because this field has not any impact with parent task.
Query 2 : However is it possible for you to provide code snippet for achieving (including the ability to save the resource list) this for newly added task.
Solution : We request you to set the name of resource id field same for both TaskData and Resources Datasources.
Code Snippet:
[CS] // Gantt Data Fields public class TaskData { public string TaskId { get; set; } public string TaskName { get; set; } //... public List<int> ResourceID { get; set; } //...
} // Resource Data Fields public class myDropDown { public string ResourceID { get; set; } public string ddtext { get; set; } }
[CSHTML] @(Html.EJ().Gantt("Gantt"). TaskIdMapping("TaskId"). //...
//To Set the resources
ResourceInfoMapping("ResourceID").// "Resource" which is defined in Gantt data object ResourceIdMapping("ResourceID").//"ResourceID" which is defined in Resource datasource ResourceNameMapping("ddtext"). //"ddtext" which is defined in Resource datasource.
//...
) |
We have prepared a sample based on your above requirement, find the sample from below location.
Query 3 : Also another question regarding Gantt chart. It seems the Parent resource list is not editable.
Solution : We can edit the Resource list of parent task with cell editing. Now we have noticed that we cannot edit the parent resource list with edit dialogue box and consider this is an issue, so we have logged an issue report on this. Also we have created a support incident under your account to track the status of this issue.
Please log on to our support website to check for further updates.
Link : https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents
Please let us know if you need further assistance on this.
Regards,
Dinesh kumar.N
Hi Prasanth,
We can save the newly added task to SQL database using AJAX post method in “ActionComplete” client side event. Please find the code snippet from below,
Code Snippet :
[CSHTML]
<script type="text/javascript"> function ActionComplete(args) { if (args.requestType === 'save' && args.addedRecord) { addedItem = args.addedRecord.item; var addedRecord = JSON.stringify({ 'Task': addedItem, 'Resource': args.addedRecord.resourceInfo }); $.ajax({ type: "POST", url: "/Gantt/Add",//Add is Server side method data: addedRecord, traditional: true, contentType: 'application/json' }); } </script>
[CS]
[HttpPost()] public void Add(GanttData Task, List<myDropDown> Resource) { //Using INSERT Query to add the New Record to SQL Table } |
We have prepared a sample based on your requirement, find the sample from below location.
Sample: http://www.syncfusion.com/downloads/support/forum/121423/ze/MVCsampleSQL1469588783
Please let us know, if you need further assistance on this.
Regards,
Dinesh kumar.N