PDA

View Full Version : Problem with Grid and XML Data loading


jcarey03
12-02-2006, 06:39 PM
I have been trying to get xml data loaded into a grid. I looked at the code example posted: http://www.jackslocum.com/blog/2006/08/31/a-grid-component-for-yahoo-ui-part-2/ and modeled my code after it. When I run my code, there is no data displayed in the grid and no errors. All the files exist locally on my machine. I noticed other people have had this problem as well, but I have not seen a solution to it. Please help.

Thanks,
Jason

Here is some of my code:

var SubscriptionGrid = {
init : function(){
var schema = {
tagName: 'subscription',
id: 'id',
fields: ['title', 'status', 'lastUpdate']
};
dataModel = new YAHOO.ext.grid.XMLDataModel(schema);

// the DefaultColumnModel expects this blob to define columns. It can be extended to provide
// custom or reusable ColumnModels
var colModel = new YAHOO.ext.grid.DefaultColumnModel([
{header: "Subscription", width: 180, sortable: true},
{header: "Status", width: 100, sortable: true},
{header: "Last Update", width: 100, sortable: true}
]);

// create the Grid
var grid = new YAHOO.ext.grid.Grid('subscriptionWrapper', dataModel, colModel);
grid.autoWidth = true;
grid.autoHeight = true;
grid.render();
dataModel.load('../../data/subscription.xml', '');
}
}
YAHOO.ext.EventManager.onDocumentReady(SubscriptionGrid.init, SubscriptionGrid, true);

tryanDLS
12-02-2006, 07:02 PM
Did you try setting a breakpoint in the load routine to see if your data is even getting loaded. You say 'no errors' - does that mean you wrapped the load with a try/catch, or just don't see any script errors reported?

There is a complete example of an xml grid in docs - you should be able to run that locally with only minor tweaks to account for your xml schema.

If that fails you might try posting a link, or a more complete sample, including the HTML and XML.

pomata
12-02-2006, 08:17 PM
Make sure in your data u got the id node.

happened to me I just returned fields in xml, but it needs one more for id.....


not sure is your case.

Regards

tryanDLS
12-02-2006, 08:35 PM
If your data doesn't have an id node, change your schema to say id: 'use-index' instead of id:id.

jack.slocum
12-03-2006, 07:48 AM
If the "files exist on your local machine" you will need to put them on a server (install apache locally if you must). XMLHTTPRequest cannot load from the local file system.

jcarey03
12-03-2006, 08:35 PM
Thanks - that worked!