2012-03-29 8 views
2

を使用してExtJSの4にレンダリングされていないHTMLファイルのsrcコードGRIDが正しくここストア

<!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> 

ファイルパスです:/bh/Main.js [メインファイル]

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' 
     } 
     ] 
    }); 
} 
}); 

ファイルパス:/app/controller/UserController.js [コントローラー]

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

ファイルのパス:/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' 
    } 
}); 

ファイルパス:/app/model/UserModel.js [モデル]

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'} 
] 
}); 

ファイルパス:/app/view/UserList.js [表示]

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); 
} 

}) ;次のように

は、火災のバグでは、JSONレスポンスを示しています。私は、有効なJSONレスポンスを持っているが、データが表示されていないのはなぜ

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

。助けてください!!!

enter image description here

+0

ああワットは、私が書いた本である拡張の代わりに、それをファイルストアに延びています'Ext.data.Model' – aswininayak

+0

有効なJSON応答がありますが、ストアにレコードがありますか? – sha

+0

あなたが持っている場合は、ソリューションを共有していただけますか? – Patton

答えて

0

私はあなたが適切ストアをロードしませんでしたので、あなたのグリッドがロードされなかったと信じています。あなたは使うべきです。

this.getStore('userStore').load(); 

代わりの

this.getUserStoreStore().load(); 
+0

これらの2つの呼び出しは、ストアを定義したコントローラー内で使用すると同等です。 – VoidMain

0

あなたはこのように、代理で自分のリーダーを構成する必要があります。

Ext.define('App.store.UserStore', { 
    extend: 'Ext.data.Store', 
    model: 'App.model.UserModel', 
    proxy: { 
     type: 'ajax', 
     url: 'app/data/contact.json', 
     reader: { 
      type: 'json' 
     } 
    } 
}); 
関連する問題