PDA

View Full Version : Data in Grid Not shown



ridhopahwanae
10 Feb 2012, 12:45 AM
I nubie in extjs 4.0 for mvc. I have treepanel that has leaf node. When i click leaf node "country" it will load data and display the data to the grid
Here is my code

Controller
System.js


Ext.define('travel.controller.System', {
extend: 'Ext.app.Controller',
views: [
'interface.North',
'interface.Center',
'interface.West',
'interface.East',
'interface.menu.Treemenu',
'center.CountryList'
],
stores: [
'StoreCountry'
],
models: [
'CountryModel'
],
init: function() {
this.control({
'treemenu': {
itemclick: this.editUser
}
});
},
editUser: function(record) {

if (Ext.getCmp('treemenu1').getSelectionModel().selected.items[0].data.text=='Country'){
this.getStoreCountryStore().load();

}
}
});



View
CountryList.js


Ext.define('travel.view.center.CountryList' ,{
extend: 'Ext.grid.Panel',
alias : 'widget.countryList',

title : 'All Country',

store: 'StoreCountry',
iconCls: 'silk-grid',
columns: [
{id:'entity_id',header: 'entity_id', width: 300, sortable: true,dataIndex:'id', flex: 1},
{header: 'entity_name', width: 160,dataIndex:'entity_name'}
],
//stripeRows: true,
//autoExpandColumn: 'No',
height: 350,
width: 750,
header:false,
autoScroll:true,

initComponent: function() {
this.callParent(arguments);
}
});



Model
CountryModel.js

Ext.define('travel.model.CountryModel', {
extend: 'Ext.data.Model',
fields: ['entity_id', 'entity_name']
});

Store
Country.js


Ext.define('travel.store.StoreCountry', {
extend: 'Ext.data.Store',
autoLoad:true,
model: 'travel.model.CountryModel',
proxy: new Ext.data.HttpProxy(
{
url: 'app/model/include/case_store.php',
method: 'POST',
timeout:1000000
}),reader: new Ext.data.JsonReader(
{
root: 'results',
totalProperty: 'total'
},
[
{name:'entity_id',type:'string'},
{name:'entity_name',type:'string'}]
)
});


json


[{"entity_id":"1","entity_name":"Afghanistan","fullname":"Islamic State of Afghanistan","capital":"Kabul","currency_code":"AFN","no":1},{"entity_id":"2","entity_name":"Albania","fullname":"Republic of Albania","capital":"Tirana","currency_code":"ALL","no":2},{"entity_id":"3","entity_name":"Algeria","fullname":"People's Democratic Republic of Algeria","capital":"Algiers","currency_code":"DZD","no":3},{"entity_id":"4","entity_name":"Andorra","fullname":"Principality of Andorra","capital":"Andorra la Vella","currency_code":"EUR","no":4},{"entity_id":"5","entity_name":"Angola","fullname":"Republic of Angola","capital":"Luanda","currency_code":"AOA","no":5},{"entity_id":"6","entity_name":"Antigua and Barbuda","fullname":"","capital":"Saint John's","currency_code":"XCD","no":6},{"entity_id":"7","entity_name":"Argentina","fullname":"Argentine Republic","capital":"Buenos Aires","currency_code":"ARS","no":7},{"entity_id":"8","entity_name":"Armenia","fullname":"Republic of Armenia","capital":"Yerevan","currency_code":"AMD","no":8},{"entity_id":"9","entity_name":"Australia","fullname":"Commonwealth of Australia","capital":"Canberra","currency_code":"AUD","no":9},{"entity_id":"10","entity_name":"Austria","fullname":"Republic of Austria","capital":"Vienna","currency_code":"EUR","no":10},{"entity_id":"11","entity_name":"Azerbaijan","fullname":"Republic of Azerbaijan","capital":"Baku","currency_code":"AZN","no":11},{"entity_id":"12","entity_name":"Bahamas, The","fullname":"Commonwealth of The Bahamas","capital":"Nassau","currency_code":"BSD","no":12},{"entity_id":"13","entity_name":"Bahrain","fullname":"Kingdom of Bahrain","capital":"Manama","currency_code":"BHD","no":13},{"entity_id":"14","entity_name":"Bangladesh","fullname":"People's Republic of Bangladesh","capital":"Dhaka","currency_code":"BDT","no":14},{"entity_id":"15","entity_name":"Barbados","fullname":"","capital":"Bridgetown","currency_code":"BBD","no":15},{"entity_id":"16","entity_name":"Belarus","fullname":"Republic of Belarus","capital":"Minsk","currency_code":"BYR","no":16},{"entity_id":"17","entity_name":"Belgium","fullname":"Kingdom of Belgium","capital":"Brussels","currency_code":"EUR","no":17},{"entity_id":"18","entity_name":"Belize","fullname":"","capital":"Belmopan","currency_code":"BZD","no":18},{"entity_id":"19","entity_name":"Benin","fullname":"Republic of Benin","capital":"Porto-Novo","currency_code":"XOF","no":19},{"entity_id":"20","entity_name":"Bhutan","fullname":"Kingdom of Bhutan","capital":"Thimphu","currency_code":"BTN","no":20}]




the data in grid country is blank (data not shown) but data in json is exist and no error in firebug


Thanks for answer

ridhopahwanae
10 Feb 2012, 1:36 AM
it's solved

I change Country Store


Ext.define('travel.store.StoreCountry', {
extend: 'Ext.data.Store',
autoLoad:true,
model: 'travel.model.CountryModel',
proxy: {
type: 'ajax',
url: 'app/model/include/case_store.php',
reader: {
type: 'json',
root: 'results'
}
}
});

thanks sencha