GRID is not properly rendered in ExtJS 4 by using Store

Posted by user548543 on Stack Overflow See other posts from Stack Overflow or by user548543
Published on 2012-03-29T12:32:00Z Indexed on 2012/04/09 5:28 UTC
Read the original article Hit count: 305

Filed under:
|
|
|

Here is the Src code for HTML file

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4 /strict.dtd">
<html>
<head>
<title>MVC Architecture</title>
<link rel="stylesheet" type="text/css" href="/bh/extjs/resources/css/ext-all.css" />
<script type="text/javascript" src="extjs/ext-debug.js"></script>
<script type="text/javascript" src="Main.js"></script>
</head>
<body>
</body>
</html>

File path: /bh/Main.js [Main File]

Ext.require('Ext.container.Viewport');
Ext.application({
name: 'App',
appFolder: 'app',
controllers: ['UserController'],

launch: function() {

Ext.create('Ext.container.Viewport', {
layout: 'border',
items: [
        {
            xtype: 'userList'
        }
       ]
  });
 }
});

File path: /app/controller/UserController.js [Controller]

Ext.define('App.controller.UserController',{
 extend: 'Ext.app.Controller',
 stores: ['UserStore'],
 models:['UserModel'],
 views:['user.UserList'],
 init: function() {
  this.getUserStoreStore().load();
  }
});

File path: /app/store/UserStore.js

 Ext.define('App.store.UserStore', {
  extend: 'Ext.data.Store',
  model: 'App.model.UserModel',

  proxy: {
   type: 'ajax',
   url: 'app/data/contact.json'
  }
});

File path: /app/model/UserModel.js [Model]

Ext.define('App.model.UserModel',{
extends:'Ext.data.Model',
fields:[
    {name: 'name', type: 'string'},
    {name: 'age', type: 'string'},
    {name: 'phone', type: 'string'},
    {name: 'email', type: 'string'}
]
});

File path: /app/view/UserList.js [View]

Ext.define('App.view.user.UserList' ,{
extend: 'Ext.grid.Panel',
alias:'widget.userList',
title:'Contacts',
region:'center',
resizable:true,
initComponent: function() {
this.store = 'UserStore';
this.columns = [
          {text: 'Name',flex:1,sortable: true,dataIndex: 'name'},
          {text: 'Age',flex:1,sortable: true,dataIndex: 'age'},
          {text: 'Phone',flex:1,sortable: true,dataIndex: 'phone'},
          {text: 'Email',flex:1,sortable: true,dataIndex: 'email'}
        ];

this.callParent(arguments);
}

});

In fire bug it shows the JSON response as follows:

[{
  "name": "Aswini",
   "age": "32",
   "phone": "555-555-5555",
   "email": "[email protected]"
 }]

Why the Data has not been displayed although I have a valid json response. Please help!!!

enter image description here

© Stack Overflow or respective owner

Related posts about extjs

Related posts about extjs4