1. #1
    Sencha User
    Join Date
    Mar 2007
    Posts
    117
    Vote Rating
    0
    gizzmo is on a distinguished road

      0  

    Default JSONDataModel

    JSONDataModel


    Hi

    I need some help with JSONDataModel. I Can't get it to work.

    Code:
    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);
    Johan

  2. #2
    Ext Premium Member BernardChhun's Avatar
    Join Date
    Mar 2007
    Location
    Quebec, Canada
    Posts
    831
    Vote Rating
    2
    BernardChhun will become famous soon enough

      0  

    Default


    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:
    Code:
    var data = eval('(' + '{"match":[{"matchid":"5678","matchno":1,"hometeam":"arsenal","awayteam":"aston villa","homeresult":2,"awayresult":1,"matchresult":"1","status":"played"}]}' + ')');
    your JsonDataModel declaration is also wrong :
    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.

  3. #3
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    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.

  4. #4
    Sencha User
    Join Date
    Mar 2007
    Posts
    117
    Vote Rating
    0
    gizzmo is on a distinguished road

      0  

    Default


    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

  5. #5
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    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.

  6. #6
    Ext Premium Member BernardChhun's Avatar
    Join Date
    Mar 2007
    Location
    Quebec, Canada
    Posts
    831
    Vote Rating
    2
    BernardChhun will become famous soon enough

      0  

    Default


    Quote Originally Posted by gizzmo
    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
    Hey 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

  1. Getting cell value using onCellUpdated and the JSONDataModel
    By dmayer in forum Ext 1.x: Help & Discussion
    Replies: 3
    Last Post: 23 Aug 2007, 1:46 AM
  2. JSONDataModel?
    By kjordan in forum Ext 2.x: Help & Discussion
    Replies: 18
    Last Post: 19 Feb 2007, 2:21 PM
  3. two questions about JSONDataModel and pagingGrid
    By luke83 in forum Ext 1.x: Help & Discussion
    Replies: 7
    Last Post: 27 Nov 2006, 7:44 AM
  4. JSONDataModel, Understanding schema
    By irishdunn in forum Ext 1.x: Help & Discussion
    Replies: 16
    Last Post: 3 Nov 2006, 2:39 PM
  5. JSONDataModel help
    By khanh3m in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 25 Oct 2006, 4:27 PM

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi