Results 1 to 2 of 2

Thread: unable to display grid with nested json even after using has many

  1. #1
    Sencha User
    Join Date
    Mar 2013
    Location
    India
    Posts
    7
    Vote Rating
    0
      0  

    Default unable to display grid with nested json even after using has many

    I need to populate my leavehistorygrid with this json but am not able to..what am i doing wrong????

    My store is
    Code:
    Ext.define('AM.store.EMPLeaveRequest', {
        extend: 'Ext.data.Store',
        model: 'AM.model.EMPLeaveRequest',
            autoLoad: true,
         proxy: {
                type: 'ajax',
               
                url: 'data/employeeleave.json',
                autoAppendParams: false,
                reader: {
                    type: 'json'
                    
                         }
            }
    });


    My models are
    Code:
    
    
    
    Ext.define('AM.model.EMPLeaveRequest', {
        extend: 'Ext.data.Model',
        config: {
            fields  : [
                {
                    name : 'ID',
                    type : 'int'
                },
                {
                    name : 'PlAvailedCount'
                }
            ],
            hasMany : [
                {
                    model          : 'AM.model.EMPLeaveHistory',
                    name           : 'LeaveHistory',
                    associationKey : 'LeaveHistory'
                }
            ]
        }
    });
    
    Ext.define('AM.model.EMPLeaveHistory', {
        extend : 'Ext.data.Model',
        config : {
            idProperty : 'ID',
            fields: [{
                name: 'Duration'
            }, {
                name: 'ApprovedBy'
               
            }]
        }
    });

    my json
    Code:
    [
        {
            "ID": 334,
            "PLAvailedCount": "245234",
            "LeaveHistory": [
                {
                    "Duration": 43,
                    "ApprovedBy": "Shyam"
                },
                {
                    "Duration": 53,
                    "ApprovedBy": "Naveen"
                }
            ]
        }
    ]

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    Your models shouldn't use the config object
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •