PDA

View Full Version : Desktop App- Uncaught TypeError: Cannot read property 'length' of undefined



SaRPaRDa
20 Mar 2012, 1:55 AM
Hi,
I'm using Ext JS 4.0.7 Desktop Application. I'm trying to add the grid with is I defined into the window, I get error;
Uncaught TypeError: Cannot read property 'length' of undefined

If I use layout : 'anchor' into the Window function I don't get error ant my grid title is deleted finally I see only one row data.

Thank you.

Exception Details:
ext-all-debug.js, row number: 21063
this.tempHidden is undefined.


show: function() {
var i = 0,
ln = this.tempHidden.length,


Desktop Function:


var grid = GetHallTypeGrid({ gridIdSeperator: null, selectionChangeFunction: null, itemClickFunction: null, itemDoubleClickFunction: null });

var b = this.app.getDesktop(); var a = b.getWindow("hallType"); if (!a) {
a = b.createWindow({
id: "hallType", title: "Hol Tipleri", width: 600, height: 400, iconCls: "notepad", animCollapse: false, border: false, hideMode: "offsets",
layout: { type: "vbox", align: "stretch", pack:'start' },
items: [grid]
}
]
}
)
}


a.show(); return a


Grid Prepare Function:


function GetHallTypeGrid(config) {
var grdCfg = new Object(config);


var fldHallType = [
{ name: 'InsertDate', type: 'date', convert: renderDate }, { name: 'HallTypeId', type: 'string', useNull: false }, { name: 'HallTypeName', type: 'string', useNull: false }
];


var clmHallType = [
{ text: 'Hol Tipi', sortable: true, dataIndex: 'HallTypeName', flex: 1 },
{ text: 'Tarih', sortable: true, dataIndex: 'InsertDate', flex: 1, renderer: Ext.util.Format.dateRenderer('d.m.Y'), display: 'none', editor: new Ext.form.TextField({ allowBlank: false }) },
{ text: 'Hol Tipi', sortable: true, dataIndex: 'HallTypeId', hidden: true, flex: 1, editor: new Ext.form.TextField({ allowBlank: false }) },
];


var jsonAdress = new Array();
jsonAdress[0] = '/GenelTanimlar/HollType/List';
jsonAdress[1] = '/GenelTanimlar/HollType/Insert';
jsonAdress[2] = '/GenelTanimlar/HollType/Update';
jsonAdress[3] = '/GenelTanimlar/HollType/Delete';


var grid= new Ext.create('SaRPaRDa.Grid', {
moduleName: 'GeneralDefinitions',
formName: 'HallType',
idSeperator: 'Main',
jsonAdress: jsonAdress,
columns: clmHallType,
modelFields: fldHallType,
title: 'Liste',
storeAutoCreate: true,
groupFields: null
});


return grid;
}


Grid Define:


Ext.define("SaRPaRDa.Grid", {
extend: "Ext.grid.Panel",
requires: ["Ext.data.Model", "Ext.data.Store", "Ext.data.proxy.Ajax"],
alias: "widget.SaRPaRDa.Grid",
config: {
moduleName: '',
formName: '',
idSeperator: '',
jsonAdress: '',
columns: '',
modelFields: '',
title: '',
groupFields: ''
},
viewConfig: { forceFit: true },
frame: true,
flex: 1,


initComponent: function () {
clmns = this.getColumns();
ttl = this.getTitle();
nameDef = this.getModuleName() + '.' + this.getFormName() + '.' + this.getIdSeperator();


this.id = 'SaRPaRDa.Grids.' + nameDef;
this.store = this.getNewStore();
this.columns = clmns;
this.title = ttl;


SaRPaRDa.Grid.superclass.initComponent.call(this);
},


constructor: function (config) {
SaRPaRDa.Grid.superclass.constructor.call(this, config);
//this.initConfig(config);
//return this;
},


getNewStore: function () {
nameDef = this.getModuleName() + '.' + this.getFormName() + '.' + this.getIdSeperator();
jsonAdr = this.getJsonAdress();
mdlFields = this.getModelFields();
gprFields = this.getGroupFields();






if (!Ext.ModelManager.getModel('SaRPaRDa.Models.' + nameDef)) {
Ext.regModel('SaRPaRDa.Models.' + nameDef, {
id: 'SaRPaRDa.Models.' + nameDef,
fields: mdlFields,
idProperty: null,
alias: 'widget.SaRPaRDa.Models.' + nameDef
});
}


var writer = new Ext.data.JsonWriter({ encode: false, listful: true, writeAllFields: true, root: 'data', successProperty: 'success', messageProperty: 'message', allowSingle: false });


var reader = new Ext.data.JsonReader({ totalProperty: 'total', successProperty: 'success', root: 'data', messageProperty: 'message' });


var tmpProxy = new Ext.data.proxy.Ajax({
api: { read: jsonAdr[0], create: jsonAdr[1], update: jsonAdr[2], destroy: jsonAdr[3] },
reader: reader,
writer: writer,
extraParams: [{ 'usrUserId': '' }, { 'usrCompanyId': ''}],
headers: { 'Content-Type': 'application/json; charset=UTF-8' },
afterRequest: function (request, success, operation) {
if (request.operation.action != 'read') {
if (request.operation.success == true) {
for (var i = 0; i < request.operation.records.length; i++) {
request.operation.records[0].commit();
}
showMessage('info', 'ok', 'Tamam', request.operation.resultSet.message)
}
else {
for (var i = 0; i < request.operation.records.length; i++) {
request.operation.records[0].reject();
}
showMessage('error', 'ok', 'Hata', request.operation.error)
}
}
}
});


var tmpStore = new Ext.create('Ext.data.Store', {
model: 'SaRPaRDa.Models.' + nameDef,
id: 'SaRPaRDa.Stores.' + nameDef,
groupField: gprFields,
autoLoad: true,
autoSync: false,
proxy: tmpProxy
});
return tmpStore;
}
});

vietits
20 Mar 2012, 2:06 AM
This is a bug in Ext 4.0.7. You can fix this by override the Ext.ZIndexManager as below


Ext.define('MyDesktop.override.ZIndexManager', {
override: 'Ext.ZIndexManager',

show: function() {
for (var idx = 0, len = this.tempHidden ? this.tempHidden.length : 0; idx < len; idx++) {
var comp = this.tempHidden[idx];
comp.show();
comp.setPosition(comp.x, comp.y);
}
delete this.tempHidden;
}
});

SaRPaRDa
20 Mar 2012, 2:32 AM
Thank you so much vietits

andyproxis
22 Mar 2012, 12:39 AM
Just added it and it works... Maybe Sencha can update code - i think many have same problem, they just dont write on forum...

vietits
22 Mar 2012, 1:52 AM
This bug has been fixed in Ext 4.1.0-beta-1 or greater.