1. #11
    Sencha User
    Join Date
    Apr 2012
    Posts
    82
    Answers
    4
    Vote Rating
    3
    matfin is on a distinguished road

      0  

    Default


    Hey,

    Thanks for the help so far but unfortunately no luck - here is the code I have been trying for reference - is there something I'm completely missing here?

    Group.js model

    Code:
    Ext.define('Application.model.Group', {
    	extend: 'Ext.data.Model',
    	config:	{
    		fields: [
    			{name: 'name', type: 'string'}
    		]},
    		hasMany: {model: 'Team', name: 'teams'}
    		/*
    		associations: [
    			{type: 'hasMany', model: 'Team', name: 'teams'}
    		]
    		*/
    });
    Team.js model

    Code:
    Ext.define('Application.model.Team', {
    	extend: 'Ext.data.Model',
    	config:	{
    		fields: [
    			{name: 'id', type: 'string'},
    			{name: 'team_info', type: 'string'},
    			{name: 'against', type: 'int', mapping: 'competition_data.Against'}
    		]},
    		belongsTo: 'Group'
    		//belongsTo: {model: 'Group', name: 'group'}
    		/*
    		associations: [
    			{type: 'belongsTo', model: 'Group', name: 'group'}
    		]
    		*/
    });

  2. #12
    Sencha - Community Support Team edspencer's Avatar
    Join Date
    Jan 2009
    Location
    Palo Alto, California
    Posts
    1,939
    Answers
    29
    Vote Rating
    7
    edspencer is a jewel in the rough edspencer is a jewel in the rough edspencer is a jewel in the rough

      0  

    Default


    I think the problem is your associations are still being defined outside the config object. They need to move inside. Your indentation actually hides the issue - if I reformat your code to use a consistent indentation approach it looks like this:

    Code:
    Ext.define('Application.model.Group', {
        extend: 'Ext.data.Model',
        config: {
            fields: [
                {name: 'name', type: 'string'}
            ]
        },
        hasMany: {
            model: 'Team',
            name: 'teams'
        }
    });
    Note that the hasMany is outside the config object. It needs to move inside the config object so it ends up looking like this:

    Code:
    Ext.define('Application.model.Group', {
        extend: 'Ext.data.Model',
        config: {
            fields: [
                {name: 'name', type: 'string'}
            ],
            
            hasMany: {
                model: 'Team',
                name: 'teams'
            }
        }
    });
    The same applies to the Team model
    Ext JS Senior Software Architect
    Personal Blog: http://edspencer.net
    Twitter: http://twitter.com/edspencer
    Github: http://github.com/edspencer

  3. #13
    Sencha User
    Join Date
    Apr 2012
    Posts
    82
    Answers
    4
    Vote Rating
    3
    matfin is on a distinguished road

      0  

    Default


    Hi,

    Thanks for helping me out but tried that and still no luck unfortunately. Been trawling the internet too for an answer and so many places give so many different ways to do things. Here is my code now:

    Group.js

    Code:
    Ext.define('Application.model.Group', {
    	extend: 'Ext.data.Model',
    	config:	{
    		fields: [
    			{name: 'name', type: 'string'}
    		],
    		hasMany: {model: 'Team', name: 'teams'}
    	}
    });
    Team.js

    Code:
    Ext.define('Application.model.Team', {
    	extend: 'Ext.data.Model',
    	config:	{
    		fields: [
    			{name: 'id', type: 'string'},
    			{name: 'team_info', type: 'string'},
    			{name: 'against', type: 'int', mapping: 'competition_data.Against'}
    		],
    		belongsTo: {model: 'Group', name: 'group'}
    	}
    });


    Do I have to do anything in the Store for Groups to loop through each Group model and associate each team with it or should each team encountered be automatically instantiated and assigned to the correct group?

    I've read about association keys, are they something that has been deprecated or for some other reason is no longer needed?

  4. #14
    Sencha - Community Support Team edspencer's Avatar
    Join Date
    Jan 2009
    Location
    Palo Alto, California
    Posts
    1,939
    Answers
    29
    Vote Rating
    7
    edspencer is a jewel in the rough edspencer is a jewel in the rough edspencer is a jewel in the rough

      0  

    Default


    Oh - you're not fully qualifying the model name. Try this:

    Code:
    Ext.define('Application.model.Group', {
    	extend: 'Ext.data.Model',
    	config:	{
    		fields: [
    			{name: 'name', type: 'string'}
    		],
    		hasMany: {
    		    model: 'Application.model.Team',
    		    name: 'teams'
    		}
    	}
    });
    Ext JS Senior Software Architect
    Personal Blog: http://edspencer.net
    Twitter: http://twitter.com/edspencer
    Github: http://github.com/edspencer

  5. #15
    Sencha User
    Join Date
    Apr 2012
    Posts
    82
    Answers
    4
    Vote Rating
    3
    matfin is on a distinguished road

      0  

    Default


    It worked (almost) so thank you so much for that - only thing is it's only returning the first team for each group pulled from the json feed as opposed to all four teams. Must figure out how I can get it to access all teams.

    Thanks a million!

    Matt

  6. #16
    Sencha User
    Join Date
    Apr 2012
    Posts
    82
    Answers
    4
    Vote Rating
    3
    matfin is on a distinguished road

      0  

    Default


    Only one team was coming up for each group and I've found the culprit:

    In Team.js I had the line

    Code:
    belongsTo: {model: 'Application.model.Group', name: 'groups'}
    
    which would then load the group for the team, which in turn would load the team for that group and it must have been caught in an infinite loop - possibly a bug ?

    I took it out and now the group with all teams associated with them are loading correctly.

    Once again thanks a million for your help

  7. #17
    Sencha - Community Support Team edspencer's Avatar
    Join Date
    Jan 2009
    Location
    Palo Alto, California
    Posts
    1,939
    Answers
    29
    Vote Rating
    7
    edspencer is a jewel in the rough edspencer is a jewel in the rough edspencer is a jewel in the rough

      0  

    Default


    That's weird... the name: 'groups' is actually not required in that association anyway, maybe it's interfering. If not that could well be a bug.

    Anyway glad you got it working
    Ext JS Senior Software Architect
    Personal Blog: http://edspencer.net
    Twitter: http://twitter.com/edspencer
    Github: http://github.com/edspencer

  8. #18
    Sencha Premium Member
    Join Date
    Oct 2012
    Location
    Antibes
    Posts
    66
    Answers
    4
    Vote Rating
    0
    Gaspard22 is on a distinguished road

      0  

    Default


    I have the same issue, with my associations , my 'docs' are empty
    • data: Object
      • CON_BIRTHDAY: Mon Jan 19 1942 01:00:00 GMT+0100 (Paris, Madrid)
      • CON_FIRSTNAME: "Alain"
      • CON_ID: "1"
      • CON_LASTNAME: "ESSAI"
      • CON_MAIL: "sebastien@fsd-france.com"
      • CON_MSG: "Envoyer un courrier↵Prendre rendez-vous"
      • GRP_ID: 3
      • UPL_ID: "1"
      • docs: Array[0]
    this is the result of console.log(record.getData(true));
    • raw: Object
      • ADR_ID: "62"
      • COF_ID: "1"
      • CON_BIRTHDAY: "1942-01-19"
      • CON_DELETE: "0"
      • CON_FIRSTNAME: "Alain"
      • CON_ID: "1"
      • CON_LASTNAME: "ESSAI"
      • CON_MAIL: "sebastien@fsd-france.com"
      • CON_MSG: "Envoyer un courrier↵Prendre rendez-vous"
      • CON_SOURCE: "professionnel"
      • CPD_ID: "4"
      • GEN_ID: "1"
      • GRP_ID: "3"
      • UPL_ID: "1"
      • docs: Array[8]
    • What was the trick for making this work ?

Thread Participants: 2

Tags for this Thread

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