BoldDeskWe are launching BoldDesk on Product Hunt soon. Learn more & follow us.
Hi Franjkovic,
Thanks for using Syncfusion products.
We would like to let you know that, in Gantt control, we can read or save the data to the SQL database while adding, deleting and updating the record. But it can be achieved only through ASP.NET or ASP.NET MVC platform with the help of following client side events.
1. ActionComplete
2. TaskbarEdited and
3. EndEdit
Please refer the following code snippets for retrieving the data while adding, deleting and updating the record in JS platform.
Code snippets:
<script type="text/javascript"> $(function () {
$("#gantt").ejGantt({ //... taskbarEdited: taskbarEdited, endEdit: endEdit, actionComplete: actionComplete,
}); }); // To update the database while cell editing function endEdit(args) { var obj = $("#gantt").data("ejGantt"); if (args.data && args.type === 'endEdit' && args.previousValue) var ganttRec = args.data.item; //Edited Record is obtained here , which can be updated to database //To retrieve datasource after updating a record var currentDatasource = obj.model.dataSource; }
// To update the database while editing the taskbar item function taskbarEdited(args) { var obj = $("#gantt").data("ejGantt"); if (args.data && args.type === 'taskbarEdited' && args.previousData) var ganttRec = args.data.item; //Edited Record is obtained here , which can be updated to database //To retrieve datasource after updating a record var currentDatasource = obj.model.dataSource; }
// To update the database through dialog editing or tool bar editing function actionComplete(args) {
var ganttRecord = args.data, obj = $("#gantt").data("ejGantt"); if (args.requestType === 'save' && args._cAddedRecord) { //Newly Added Record is obtained here , which can be updated to database
if (args._cAddedRecord.parentItem) ganttRecord["ParentId"] = args._cAddedRecord.parentItem.taskId; var newRecord = ganttRecord; // This variable holds the data of the new record which is to be added in database
//To retrieve datasource after adding a record var currentDatasource = obj.model.dataSource;
} else if (args.requestType === 'save') { //Edited Record is obtained here , which can be updated to database
if (args._cModifiedData.parentItem) ganttRecord["ParentId"] = args._cModifiedData.parentItem.taskId; ganttRecord["Predecessor"] = args._cModifiedData.item.Predecessor;
var updatedRecord = ganttRecord; // data to be updated in database
//To retrieve datasource after updating a record var currentDatasource = obj.model.dataSource; } else if (args.requestType === 'delete') { var data =args.data; var ganttRec = data.item; // It is the data which is to be deleted in database
//To retrieve datasource after deleting a record var currentDatasource = obj.model.dataSource; }
// To update the database during Indent operation else if (args.requestType === 'endedit') {
var ganttRec = args.data.item; var updatedRecord = ganttRec; // data to be updated in database
//To retrieve datasource after updating a record var currentDatasource = obj.model.dataSource; } // To update the database during Outdent operation else if (args.requestType === 'actionComplete') { var ganttRec = args.data.item; if (args.data.parentItem) ganttRec["ParentId"] = args.data.parentItem.taskId;
var updatedRecord = ganttRec; // data to be updated in database
//To retrieve datasource after updating a record var currentDatasource = obj.model.dataSource; } } </script> |
Please find the following online KB links for updating SQL database.
1. ASP.NET platform
Link: https://www.syncfusion.com/kb/3086/how-to-add-delete-and-update-the-sql-database-through-gantt
2. ASP.NET MVC platform
Link: https://www.syncfusion.com/kb/3085/how-to-add-delete-and-update-the-sql-database-through-gantt
We have also prepared a sample in JS platform. Please find the sample in the following location.
Sample: http://www.syncfusion.com/downloads/support/directtrac/general/Vol4_SP1_sample-1473417007.zip
Please let us know if you need more information on this.
Regards,
John. R