0

I have Json data something like this:

{

"Data":

    {
    "Columns":
    [
        {
            "Name":"Name",
            "Format":"string"
        },
        {
            "Name":"Age",
            "Format":"N2"
        }
    ],
    "Rows":
    [
        {"ExtensionData":{},"Cells":["Vikas", 23],"Emails":[{"ExtensionData": }, Email": [email protected]", "CellOrdinal":0}]},
        {"ExtensionData":{},"Cells":["Vikram", 27],"Emails":[{"ExtensionData":{},"Email":"[email protected]","CellOrdinal":0}]},     
    ]
    }
    "Grid Name":"Users"
    }
}
}

I need to bind this to my grid.

The "Columns" tag contains grid column names. "Rows" contain records of the grid. Also there are some data like Name of the grid which is fetched from the database. It's a slightly complicated structure.

How to get this data into a store? How should my model be?

2
  • Sorry ...could not format Json data properly!!! Commented May 19, 2011 at 14:37
  • I just want to mention that you also have a code button {} to format ;) Commented May 19, 2011 at 14:45

1 Answer 1

4

Atlast after lot of trial and error got the model ready...

Ext.define('Data', {
    extend: 'Ext.data.Model',
    fields: [
            { type: 'string', name: 'Grid Name' }
        ],
    hasMany: [{ model: 'Column', name: 'Columns' },
              { model: 'Row', name: 'Rows' }]
});

Ext.define("Column", {
    extend: 'Ext.data.Model',
    fields: [
            { type: 'string', name: 'Name' },
            { type: 'string', name: 'Format' }
        ],
    belongsTo: 'Data'
});

Ext.define("Row", {
    extend: 'Ext.data.Model',
    fields: [
            { type: 'string', name: 'Cells' },
            { type: 'string', name: 'Emails' }
        ],
    belongsTo: 'Data'
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.