PDA

View Full Version : Grid Not Loaded



fastwings
3 Jan 2011, 12:57 PM
i got this code:



///<reference path="http://extjs.cachefly.net/ext-3.2.1/adapter/ext/ext-base-debug.js" />
///<reference path="http://extjs.cachefly.net/ext-3.0.0/ext-all-debug.js" />
///<reference path="../Utills.js" />
///<reference path="../../Events/MainMenu/Main.js" />
///<reference path="../../Utills/Utills.js" />
///<reference path="../../Utills/CookieObject.js" />
///<reference path="http://extjs.cachefly.net/ext-3.2.1/adapter/ext/ext-base-debug.js" />
///<reference path="http://extjs.cachefly.net/ext-3.0.0/ext-all-debug.js" />
Ext.ns('Ext.Admin.UI.Panels.Factory');
var FactoryGrids = {
Instance: null,
DataSource: null,
JsEval: "",
ObjctJsonDef: null,
RowEditor: null,
RunParams: [],
Init: function (js)
{
var based = this;
based.JsEval = js;
},
Run: function (type)
{
var based = this;
based._loadDs();
switch (type.toLowerCase())
{
case 'simple':
based._buildSimpleGrid();
break;
}
based.Instance.show();
return based.Instance;
},
_loadDs: function ()
{
var based = this;
based.ObjctJsonDef = Ext.data.Record.create([{
name: 'ID',
type: 'int'
}, {
name: 'Key',
type: 'string'
}, {
name: 'Name',
type: 'string'
}]);

based.DataSource = new Ext.data.Store({
autoLoad: true,
autoDestroy: true,
url: '/Webservices/DataControl.ashx?cmd=getCurrencys',
reader: new Ext.data.JsonReader({ fields: based.ObjctJsonDef,
idProperty: 'ID', root: "records", totalProperty: "total", successProperty: "success"
}),
sortInfo: { field: 'Key', direction: 'ASC' }
});

},
_buildSimpleGrid: function ()
{
var based = this;
based.RowEditor = new Ext.ux.grid.RowEditor({
saveText: 'Update'
});
based.Instance = new Ext.grid.GridPanel({
store: based.DataSource,
width: 600,
autoDestroy: true,
autoShow: true,

region: 'center',
margins: '0 5 5 5',
autoExpandColumn: 'Name',
/* view: new Ext.grid.GroupingView({
markDirty: false
}),
tbar: [{
iconCls: 'icon-user-add',
text: 'Add Currency',
handler: function ()
{
var e = new based.ObjctJsonDef({
Key: 'ISR',
Name: 'Israel'
});
based.RowEditor.stopEditing();
based.DataSource.insert(0, e);
based.Instance.getView().refresh();
based.Instance.getSelectionModel().selectRow(0);
based.RowEditor.startEditing(0);
}
}, {
ref: '../removeBtn',
iconCls: 'icon-user-delete',
text: 'Remove Currency',
disabled: true,
handler: function ()
{
based.RowEditor.stopEditing();
var s = based.Instance.getSelectionModel().getSelections();
for (var i = 0, r; r = s[i]; i++)
{
based.DataSource.remove(r);
}
}
}],
*/
columns: [based._loadGridColumes()]
});
},
_loadGridColumes: function ()
{
var columes = [];
var colume = {};
colume = {
header: 'Key',
dataIndex: 'Key',
width: 220,
sortable: true,
editor: {
xtype: 'textfield',
allowBlank: false
}
};
columes.push(colume);
colume = {
header: 'Name',
dataIndex: 'Name',
width: 220,
sortable: true,
editor: {
xtype: 'textfield',
allowBlank: false
}
};
columes.push(colume);
return columes;
}
};

// var myStore = new Ext.data.JsonStore({
// // Load data at once
// // autoLoad: true,
// // Override default http proxy settings
// // proxy: new Ext.data.HttpProxy({
// // // Call web service method using GET syntax
// // url: 'Service1.svc/PostToGetList',
// // // Ask for Json response
// // headers: this.header || { 'Content-Type': 'application/json;charset=utf-8' },

// // listeners: {
// // exception: function (dp, type, action, options, response, arg)
// // {
// // // Error handling
// // }
// // },
// // method: 'POST'

// // }),
// // Root variable
// root: 'd',
// // Record identifier
// id: 'VPValue',
// // Fields declaration
// fields: ['VPValue', 'VPDes']
// });


i have response from server on this json:


{"records":[{"Key":"AFA","Name":"Afghani","ID":1},{"Key":"DZD","Name":"Algerian Dinar","ID":2},{"Key":"ARS","Name":"Argentine Peso","ID":3},{"Key":"AMD","Name":"Armenian Dram","ID":4},{"Key":"AWG","Name":"Aruban Guilder","ID":5},{"Key":"AUD","Name":"Australian Dollar","ID":6},{"Key":"AZM","Name":"Azerbaijanian Manat","ID":7},{"Key":"BSD","Name":"Bahamian Dollar","ID":8},{"Key":"BHD","Name":"Bahraini Dinar","ID":9},{"Key":"THB","Name":"Baht","ID":10},{"Key":"PAB","Name":"Balboa","ID":11},{"Key":"BBD","Name":"Barbados Dollar","ID":12},{"Key":"BEF","Name":"Belgian Franc","ID":13},{"Key":"VEB","Name":"Bolivar","ID":14},{"Key":"BOB","Name":"Boliviano","ID":15},{"Key":"BRL","Name":"Brazilian Real","ID":16},{"Key":"BND","Name":"Brunei Dollar","ID":17},{"Key":"BGN","Name":"Bulgarian Lev","ID":18},{"Key":"CAD","Name":"Canadian Dollar","ID":19},{"Key":"GHC","Name":"Cedi","ID":20},{"Key":"XOF","Name":"CFA Franc BCEAO","ID":21},{"Key":"CLP","Name":"Chilean Peso","ID":22},{"Key":"COP","Name":"Colombian Peso","ID":23},{"Key":"CRC","Name":"Costa Rican Colon","ID":24},{"Key":"HRK","Name":"Croatian Kuna","ID":25},{"Key":"CYP","Name":"Cyprus Pound","ID":26},{"Key":"CZK","Name":"Czech Koruna","ID":27},{"Key":"DKK","Name":"Danish Krone","ID":28},{"Key":"DEM","Name":"Deutsche Mark","ID":29},{"Key":"DOP","Name":"Dominican Peso","ID":30},{"Key":"VND","Name":"Dong","ID":31},{"Key":"GRD","Name":"Drachma","ID":32},{"Key":"EGP","Name":"Egyptian Pound","ID":33},{"Key":"SVC","Name":"El Salvador Colon","ID":34},{"Key":"AED","Name":"Emirati Dirham","ID":35},{"Key":"EUR","Name":"EURO","ID":36},{"Key":"FJD","Name":"Fiji Dollar","ID":37},{"Key":"HUF","Name":"Forint","ID":38},{"Key":"FRF","Name":"French Franc","ID":39},{"Key":"PYG","Name":"Guarani","ID":40},{"Key":"HKD","Name":"Hong Kong Dollar","ID":41},{"Key":"ISK","Name":"Iceland Krona","ID":42},{"Key":"INR","Name":"Indian Rupee","ID":43},{"Key":"IEP","Name":"Irish Pound","ID":44},{"Key":"ITL","Name":"Italian Lira","ID":45},{"Key":"JMD","Name":"Jamaican Dollar","ID":46},{"Key":"JOD","Name":"Jordanian Dinar","ID":47},{"Key":"KES","Name":"Kenyan Shilling","ID":48},{"Key":"EEK","Name":"Kroon","ID":49},{"Key":"KWD","Name":"Kuwaiti Dinar","ID":50},{"Key":"AOA","Name":"Kwanza","ID":51},{"Key":"LVL","Name":"Latvian Lats","ID":52},{"Key":"LBP","Name":"Lebanese Pound","ID":53},{"Key":"ALL","Name":"Lek","ID":54},{"Key":"ROL","Name":"Leu","ID":55},{"Key":"LTL","Name":"Lithuanian Litas","ID":56},{"Key":"MYR","Name":"Malaysian Ringgit","ID":57},{"Key":"MTL","Name":"Maltese Lira","ID":58},{"Key":"FIM","Name":"Markka","ID":59},{"Key":"MUR","Name":"Mauritius Rupee","ID":60},{"Key":"MXN","Name":"Mexican Peso","ID":61},{"Key":"MAD","Name":"Moroccan Dirham","ID":62},{"Key":"NGN","Name":"Naira","ID":63},{"Key":"NAD","Name":"Namibia Dollar","ID":64},{"Key":"NPR","Name":"Nepalese Rupee","ID":65},{"Key":"ANG","Name":"Netherlands Antillian Guilder","ID":66},{"Key":"NLG","Name":"Netherlands Guilder","ID":67},{"Key":"ILS","Name":"New Israeli Shekel","ID":68},{"Key":"TWD","Name":"New Taiwan Dollar","ID":69},{"Key":"NZD","Name":"New Zealand Dollar","ID":70},{"Key":"BTN","Name":"Ngultrum","ID":71},{"Key":"NOK","Name":"Norwegian Krone","ID":72},{"Key":"PEN","Name":"Nuevo Sol","ID":73},{"Key":"OMR","Name":"Omani Rial","ID":74},{"Key":"PKR","Name":"Pakistan Rupee","ID":75},{"Key":"PHP","Name":"Philippine Peso","ID":76},{"Key":"PLZ","Name":"Polish Zloty(old)","ID":77},{"Key":"PTE","Name":"Portuguese Escudo","ID":78},{"Key":"GTQ","Name":"Quetzal","ID":79},{"Key":"ZAR","Name":"Rand","ID":80},{"Key":"MVR","Name":"Rufiyaa","ID":81},{"Key":"IDR","Name":"Rupiah","ID":82},{"Key":"RUB","Name":"Russian Ruble","ID":83},{"Key":"RUR","Name":"Russian Ruble(old)","ID":84},{"Key":"SAR","Name":"Saudi Riyal","ID":85},{"Key":"ATS","Name":"Shilling","ID":86},{"Key":"SGD","Name":"Singapore Dollar","ID":87},{"Key":"SKK","Name":"Slovak Koruna","ID":88},{"Key":"ESP","Name":"Spanish Peseta","ID":89},{"Key":"LKR","Name":"Sri Lankan Rupee","ID":90},{"Key":"SEK","Name":"Swedish Krona","ID":91},{"Key":"CHF","Name":"Swiss Franc","ID":92},{"Key":"BDT","Name":"Taka","ID":93},{"Key":"SIT","Name":"Tolar","ID":94},{"Key":"TTD","Name":"Trinidad and Tobago Dollar","ID":95},{"Key":"TND","Name":"Tunisian Dinar","ID":96},{"Key":"TRL","Name":"Turkish Lira","ID":97},{"Key":"GBP","Name":"United Kingdom Pound","ID":98},{"Key":"UYU","Name":"Uruguayan Peso","ID":99},{"Key":"USD","Name":"US Dollar","ID":100},{"Key":"KRW","Name":"Won","ID":101},{"Key":"JPY","Name":"Yen","ID":102},{"Key":"CNY","Name":"Yuan Renminbi","ID":103},{"Key":"ZWD","Name":"Zimbabwe Dollar","ID":104},{"Key":"PLN","Name":"Zloty","ID":105}],"total":105,"success":true}



my problem that the grid don't show.
its been render and such
but just don't have nothing but blue line
please help

skirtle
3 Jan 2011, 2:52 PM
You have an autoExpandColumn but you haven't specified ids on your columns. Easiest way to fix this is just to set it to 1.

You're also wrapping your columns array in another array.


autoExpandColumn: 1,
columns: based._loadGridColumes()