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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback
Essential JS2

Syncfusion jQuery based widgets are no longer in active development. Switch to our pure JavaScript based next generation Essential JS 2 library.

CRUD operations example with PHP

Thread ID:

Created:

Updated:

Platform:

Replies:

148631 Oct 28,2019 05:36 PM UTC Nov 4,2019 12:37 PM UTC jQuery 3
loading
Tags: ejGantt
Razvan Nicolae
Asked On October 28, 2019 05:36 PM UTC

I have a small issue, I cannot find an example for EDIT,CREATE,DELETE for gantt in EJ2 using php, and I got stuck on using $batch, managed to process the request but ended up with the chart continuously loading after getting 200 from the api

Pooja Priya Krishna Moorthy [Syncfusion]
Replied On October 29, 2019 12:19 PM UTC

Hi Razvan, 
Greetings from Syncfusion support. 
 
We have prepared a Gantt CRUD sample using PHP version 7.1.30, fetching data from the server using dataManager. 
 
Replace the port number highlighted in the below code snippet based on your SQL port, 
 
  function update(){   
        $conn = new mysqli("localhost", "root","", "gantt", 3306);   
        //... 
  } 
 
  function add() { 
        $conn = new mysqli("localhost", "root", "", "gantt", 3306); 
        //... 
    } 
  function delete () 
    { 
        $conn = new mysqli("localhost", "root", "", "gantt", 3306); 
        //... 
    } 
 
To perform CRUD operations by using actionComplete client-side event, identify the operation by  action event argument as add, DialogEditing/ CellEditing and delete for add, edit and delete actions respectively. 
 
Please find the below code example. 
 
var gantt = new ej.gantt.Gantt({ 
   dataSource: new ej.data.DataManager({ 
       url: 'http://localhost:7777/GanttEJ2/getData.php/?action=getData', 
       crossDomain: true 
   }).executeQuery(new ej.data.Query()).then(function (e) { 
       gantt.dataSource = e.result; 
   }), 
   //... 
   actionComplete: function (args) { 
       if (args.action == "add" && args.newTaskData) { 
           var data = JSON.stringify(args.newTaskData); 
           $.ajax({ 
              type: "POST", 
              url: 'http://localhost:7777/GanttEJ2/getData.php/?action=add', 
              data: data, 
              success: function (data) { 
                 console.log(data); 
              } 
           }); 
       } 
 
       if (args.action == "DialogEditing" || args.action == "CellEditing") { 
           var data = JSON.stringify(args.data.taskData); 
           $.ajax({ 
               type: "POST", 
               url: 'http://localhost:7777/GanttEJ2/getData.php/?action=update', 
               data: data, 
                  //... 
            }); 
        } 
        if (args.action == "delete") { 
            var data = JSON.stringify(args.data[0].taskData); 
            $.ajax({ 
               type: "POST", 
               url: 'http://localhost:7777/GanttEJ2/getData.php/?action=delete', 
               data: data, 
               //... 
            }); 
        } 
     } 
}); 
 
Please get back to us if you require further assistance on this. 
 
Regards, 
Pooja Priya K. 
 


Razvan Nicolae
Replied On November 1, 2019 09:23 AM UTC

Hello Pooja,
The sample you provided me works almost perfectly, I found a flaw in it.
If I try to use the columns attribute it throws an error if I try to edit(I need to add some specific columns like Status and Trackers)
columns: [
{
field: 'TaskName',
headerText: 'Task Name',
// allowEditing: false
},
],
Here is the error: 
 Thank you,
Razvan



Saranya Dhayalan [Syncfusion]
Replied On November 4, 2019 12:37 PM UTC

Hi Razvan, 
  
We have prepared a sample by using columns attribute. We also included custom column (Status) and performed edit action. We are not able to reproduce the error. Please find the demo sample from below link. 
 
 
Could you please check the above sample and if still issue persist please modify our provided sample to reproduce the issue, so that it will be very helpful to provide you a solution. 
  
Regards, 
Saranya D 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon