The approach we used is to create an ASP.NET page that returns the JSON expected by Ext Gantt. The ASP.NET page queries a given SharePoint task list to gather the data. Here's a snippet of JavaScript from gantt.js showing how the call looks (see line referencing "GanttCallback.aspx"):
createGrid: function() {
var start = new Date('5/1/2010');
end = start.add(Date.MONTH, 10);
var store = new Ext.ux.maximgb.tg.AdjacencyListStore({
defaultExpanded: true,
autoLoad: true,
//autoLoad : false,
proxy: new Ext.data.HttpProxy({
//url : 'tasks.json',
url: 'GanttCallback.aspx?mode=getsp&s=' + siteUrl + '&w=' + webName + '&type=task&l=' + listName + '&v=' + viewName,
method: 'GET'
}),
reader: new Ext.data.JsonReader({ idProperty: 'Id' }, [
// Mandatory fields
{name: 'Id' },
{ name: 'Name', type: 'string' },
{ name: 'StartDate', type: 'date', dateFormat: 'c' },
{ name: 'EndDate', type: 'date', dateFormat: 'c' },
{ name: 'PercentDone' },
{ name: 'ParentId', type: 'auto' },
{ name: 'IsLeaf', type: 'bool' },
// Your task meta data goes here
{name: 'Responsible' },
{ name: 'EstHours' },
{ name: 'ContentType' }
]
)
});
* mode - getsp to retrieve data, putsp to save it
* siteUrl - url of site collection containing task list
* webName - web name of site containing task list
* listName - name of the source/target task list
Saving the code is also handled by a call to the web page, passing back the tasks. This time it's handled by JavaScript attached to a button embedded in gantt.html, as shown in the following snippet:
var putUrl = 'GanttCallback.aspx?mode=putsp&s=' + siteUrl + '&w=' + webName + '&l=' + listName;
function saveIt() {
// Write document back to disk w/help of ASP.NET APP
var json = getJason();
try {
xmlHttp = new XMLHttpRequest();
xmlHttp.open('POST', putUrl, true);
xmlHttp.onreadystatechange = saveItHandler;
xmlHttp.send(json);
} catch(e) {
alert ('1: '+e);
}
}
function saveItHandler (response) {
//readyState of 4 or 'complete' represents
//that data has been returned
if (xmlHttp.readyState == 4 ||
xmlHttp.readyState == 'complete')
{
// Text of web page is returned
var response = xmlHttp.responseText;
//eval (response);
window.location = loc;
}
}