mardi 21 juin 2016

Trying to load a json file to the Jquery.gantt


I'm using a jquery plugin to create a gantt chart named Jquery.Gantt I want to load a json file but unfortunately it doesn't load. this is the content of the json file. it loads the json file thru ajax but it doesn't render.

[
    {
        "name": "WORK IN PROGRESS (WIP)  MEETING",
        "desc": ""
    },{
        "name":"",
        "desc": "WIP Meeting",
        "by": "TEST DATA",
        "values": [{
            "from": "/Date(2013/05/22)/",
            "to": "/Date(2013/05/22)/",
            "customClass": "ganttGreen"
        },{
            "from": "/Date(2013/06/05)/",
            "to": "/Date(2013/06/05)/",
            "customClass": "ganttGreen"
        },{
            "from": "/Date(2013/06/19)/",
            "to": "/Date(2013/06/19)/",
            "customClass": "ganttGreen"
        },{
            "from": "/Date(2013/07/03)/",
            "to": "/Date(2013/07/03)/",
            "customClass": "ganttGreen"
        },{
            "from": "/Date(2013/07/17)/",
            "to": "/Date(2013/07/17)/",
            "customClass": "ganttGreen"
        },{
            "from": "/Date(2013/07/31)/",
            "to": "/Date(2013/07/31)/",
            "customClass": "ganttGreen"
        },{
            "from": "/Date(August 7, 2013)/",
            "to": "/Date(August 7, 2013)/",
            "customClass": "ganttGreen"
        },{
            "from": "/Date(August 14, 2013)/",
            "to": "/Date(August 14, 2013)/",
            "customClass": "ganttGreen"
        },{
            "from": "/Date(August 21, 2013)/",
            "to": "/Date(August 21, 2013)/",
            "customClass": "ganttGreen"
        },{
            "from": "/Date(August 28, 2013)/",
            "to": "/Date(August 28, 2013)/",
            "customClass": "ganttGreen"
        }]
    },{
        "name": "OVERALL EVENT COSTINGS",
        "desc": ""
    },{
        "name": "a) Budget",
        "desc": "Submission of preliminary budget",
        "by": "TEST DATA"
    },{
        "name": "a) Budget",
        "desc": "Submission of revised budget",
        "by": "TEST DATA"
    },{
        "name": "",
        "desc": "Confirmation and Sign-off of Budget",
        "by": "TEST DATA ",
        "values": [{
            "from": "/Date(July 1, 2013)/",
            "to": "/Date(July 7, 2013)/",
            "customClass": "ganttRed"
        }]
    },{
        "name": "",
        "desc": "Billing of Deposits and Invoices",
        "by": "TEST DATA",
        "values": [{
            "from": "/Date(July 1, 2013)/",
            "to": "/Date(July 7, 2013)/",
            "customClass": "ganttRed"
        }]
    },{
        "name": "",
        "desc": "Submission of final budget",
        "by": "TEST DATA",
        "values": [{
            "from": "/Date(August 5, 2013)/",
            "to": "/Date(August 18, 2013)/",
            "customClass": "ganttRed"
        }]
    },{
        "name": "",
        "desc": "Confirmation and Sign-off of Final Budget",
        "by": "TEST DATA",
        "values": [{
            "from": "/Date(August 12, 2013)/",
            "to": "/Date(August 27, 2013)/",
            "customClass": "ganttRed"
        }]
    },{
        "name": "",
        "desc": "Billing of Balance payments Invoices",
        "by": "TEST DATA",
        "values": [{
            "from": "/Date(September 9, 2013)/",
            "to": "/Date(September 15, 2013)/",
            "customClass": "ganttRed"
        }]
    },{
        "name":"EVENT CONCEPT, ID and TAGLINE"
    },{
        "name":"a) Event  Concept based on revised event ID and tagline",
        "desc":"Propose / Initial Event Concept",
        "by":"TEST DATA",
        "values": [{
            "from": "/Date(April 1, 2013)/",
            "to": "/Date(April 7, 2013)/",
            "customClass": "ganttRed"
        }]
    },{
        "name":"",
        "desc":"Revise Event Concept based on feedback",
        "by":"TEST DATA",
        "values": [{
            "from": "/Date(May 6, 2013)/",
            "to": "/Date(May 12, 2013)/",
            "customClass": "ganttRed"
        }]
    },{
        "name":"",
        "desc":"Confirmation on Event Concept",
        "by":"TEST DATA",
        "values": [{
            "from": "/Date(May 20, 2013)/",
            "to": "/Date(May 26, 2013)/",
            "customClass": "ganttRed"
        }]
    }
]

Here is my code for activating the plugin.

$(".gantt-chart").gantt({
  itemsPerPage: 15,
  source: "../../public/js/gantt-sample.json",
  scale: "days",
  minScale: "days",
  maxScale: "months",
  navigate: "scroll",
  onItemClick: function(data) {
    console.log("Item clicked - show some details");
  },
  onAddClick: function(dt, rowId) {
    console.log("Empty space clicked - add an item!");
  },
  onRender: function() {
    console.log("chart rendered");
  }
});

Aucun commentaire:

Enregistrer un commentaire