PDA

View Full Version : Error when asign result of a function to a variable



bernatbonet
14 Oct 2010, 4:58 AM
I have this funcion


function GridConfigFactory(version) {

var users_grid = new Ext.ux.AutoGrid({
autoWidth:true
,border:false
,pagesize:5
,tbar:[
new Ext.Button({
text:'add new user'
,iconCls:'icon-user_add'
,scope:this
,handler:function() {
UserEditor(arguments[0].findParentByType('AutoGrid'), '');
}
})
]
,forceFit:false
,stripRows:true
,showBbar:true
,loadMask:true
,sm:new Ext.grid.RowSelectionModel({})
,store:new Ext.data.JsonStore({
autoLoad:true
,baseParams:{}
,remoteSort:true
,sortInfo: {
field: 'id',
direction: 'DESC'
}
,proxy:new Ext.data.HttpProxy({
url:'apps/main/users_grid/' + version
,method:'POST'
})
,reader: new Ext.data.JsonReader({
root:'rows'
,id:'id'
})

})
});

return users_grid;
}

and when I call this function like this,
var a = GridConfigFactory('custom');, I got:


TypeError: undefined is not a function

and I got the result of apps/main/users_grid/custom


{"succes":true,"totalCount":1,"rows":[{"username":"","is_active":"1","email":"","is_superuser":"1","is_staff":"1","last_login":"2010-10-14 12:25:50","id":"1","date_joined":"2010-10-14 12:25:50"}],"metaData":{"sortInfo":{"field":"id","direction":"DESC"},"fields":[{"align":"center","header":"id","name":"id","width":30,"hidden":true,"id":"id","tooltip":"ID"},{"header":"username","name":"username","tooltip":"nom d'utilisateur"},{"header":"email","name":"email","tooltip":"adresse électronique"},{"name":"is_staff","width":50,"align":"center","tooltip":"statut équipe","header":"staff","renderer":function(val, attr) {attr.css = (val)?'icon-accept':'icon-delete'; },"xtype":"booleancolumn"},{"name":"is_active","width":50,"align":"center","tooltip":"actif","header":"active","renderer":function(val, attr) {attr.css = (val)?'icon-accept':'icon-delete'; },"xtype":"booleancolumn"},{"name":"is_superuser","width":50,"align":"center","tooltip":"statut super-utilisateur","header":"root","renderer":function(val, attr) {attr.css = (val)?'icon-accept':'icon-delete'; },"xtype":"booleancolumn"},{"name":"last_login","dateFormat":"d/m/Y","align":"center","format":"Y-m-d H:i:s","tooltip":"dernière connexion","header":"last_login","renderer":new Ext.util.Format.dateRenderer('d/m/Y'),"type":"date","width":90,"xtype":"datecolumn"},{"name":"date_joined","dateFormat":"d/m/Y","align":"center","format":"Y-m-d H:i:s","tooltip":"date d'inscription","header":"date_joined","renderer":new Ext.util.Format.dateRenderer('d/m/Y'),"type":"date","width":90,"xtype":"datecolumn"}],"successProperty":"success","totalProperty":"totalCount","idProperty":"id","root":"rows"}}

I don't see the error.

Thanks a lot.