-
26 Jan 2007 1:41 PM #1
JSONDataModel
JSONDataModel
Hi
I need some help with JSONDataModel. I Can't get it to work.
JohanCode:var Grid = function() { var schema; var jsonDataModel; var defaultColumnModel; var rowSelectionModel; var grid; return { initialize : function() { var schema = { root: 'match', id: 'matchid', fields: ['matchno', 'hometeam', 'awayteam'] }; jsonDataModel = new YAHOO.ext.data.JsonDataModel(schema); var defaultColumnModel = new YAHOO.ext.grid.DefaultColumnModel([ {header: "#", width: 100, sortable: true}, {header: "HomeTeam", width: 100, sortable: true}, {header: "AwayTeam", width: 100, sortable: true} ]); rowSelectionModel = new YAHOO.ext.grid.RowSelectionModel(); grid = new YAHOO.ext.grid.Grid('grid', jsonDataModel, defaultColumnModel, rowSelectionModel); grid.render(); var data = eval( {"match":[{"matchid":"5678","matchno":1,"hometeam":"arsenal","awayteam":"aston villa","homeresult":2,"awayresult":1,"matchresult":"1","status":"played"}]} ); jsonDataModel.loadData(data); }, }; }(); YAHOO.ext.EventManager.on( window, 'load', Grid.initialize, Grid, true);
-
26 Jan 2007 1:47 PM #2
you know, details about errors are always welcome... :wink: I know some of us(not me) here are debugging living machines but still...
what I'm seeing for now is your eval() line. it should be something like this if you are using eval:
your JsonDataModel declaration is also wrong :Code:var data = eval('(' + '{"match":[{"matchid":"5678","matchno":1,"hometeam":"arsenal","awayteam":"aston villa","homeresult":2,"awayresult":1,"matchresult":"1","status":"played"}]}' + ')');
Code:new YAHOO.ext.grid.JSONDataModel(schema);
ohh and use Firebug too. it's a firefox extension that helps a whole lot in debugging javascript.
-
26 Jan 2007 1:59 PM #3
Also, you're declaring the same variables inside and outside your init function. This is likely going to cause you great confusion as you proceed b/c you won't know which is in scope at a given time.
Tim Ryan
Read BEFORE posting a question / BEFORE posting a Bug
Use Google to Search - API / Forum
API Doc (4.x | 3.x | 2.x | 1.x) / FAQ / 1.x->2.x Migration Guide / 2.x->3.x Migration Guide
-
27 Jan 2007 1:28 AM #4
Hi,
I was using the 0.40 alpha version and there Jack has moved all data models to Ext.data.
I don't know if he has done some changes in them. I can't get it to work with 0.40 alpha, but
it works fine in 0.33 RC3 version.
Thanks for your quick responses
-
27 Jan 2007 7:18 AM #5
Grids are going to be broken from .33 to .40 - that's why Jack started the thread in the dev forum http://www.yui-ext.com/forum/viewtopic.php?t=1910
The new grid code is still not done and if you use it, you're going to have to work thru the instability and breaking changes pretty much on your own until the code stabilizes and it gets documented. If you're not comfortable reading the code to find out what's going on, I would suggest staying with the .33 version until the new code is released.Tim Ryan
Read BEFORE posting a question / BEFORE posting a Bug
Use Google to Search - API / Forum
API Doc (4.x | 3.x | 2.x | 1.x) / FAQ / 1.x->2.x Migration Guide / 2.x->3.x Migration Guide
-
27 Jan 2007 7:19 AM #6
Hey gizzmo,
Originally Posted by gizzmo
So you have been using the .40 alpha version... :o
Since there's no documentation on the matter yet, if I were you I'd take a peak at the code of his benchmark example in the blog as there's a big grid there made with the .40 version.
here's the url : http://www.yui-ext.com/playpen/selectors/
cheers,
Bernard
Similar Threads
-
Getting cell value using onCellUpdated and the JSONDataModel
By dmayer in forum Ext 1.x: Help & DiscussionReplies: 3Last Post: 23 Aug 2007, 1:46 AM -
JSONDataModel?
By kjordan in forum Ext 2.x: Help & DiscussionReplies: 18Last Post: 19 Feb 2007, 2:21 PM -
two questions about JSONDataModel and pagingGrid
By luke83 in forum Ext 1.x: Help & DiscussionReplies: 7Last Post: 27 Nov 2006, 7:44 AM -
JSONDataModel, Understanding schema
By irishdunn in forum Ext 1.x: Help & DiscussionReplies: 16Last Post: 3 Nov 2006, 2:39 PM -
JSONDataModel help
By khanh3m in forum Ext 1.x: Help & DiscussionReplies: 1Last Post: 25 Oct 2006, 4:27 PM


Reply With Quote