PDA

View Full Version : TypeError: 'undefined' is not an object (evaluating 'operation.getGroupers')



msweltzdk
2 Feb 2012, 2:14 AM
Using Sencha Touch 2.0 PR4 I am trying to mix dynamically obtained parameters in with the parameters already defined on a stores proxy. Yet I get thrown the error in the subject field.

I don't know if I'm missing any vital code for this problem of mine to make sense, but I would appreciate any help I can get with this issue. (And the many more that I have, but that's for other threads).

Constructor on view (want to move this to a seperate controller away from the view in the future)


// url being decoded : '#Participants/13/12/1/2012-01-01'
var url = window.location.hash.substring(1).split('/'),
urlWithNoView = window.location.hash.substring(1 + url[0].length).split('/'),
params = { 'Sel': urlWithNoView[0], 'Afd': urlWithNoView[1], 'Afsnit': urlWithNoView[2], 'tdate': urlWithNoView[3] };

var storeManagement = Ext.getStore('ParticipantBoards'),
proxyManagement = storeManagement.getProxy();

Ext.apply(params, proxyManagement.getParams()); <-- this is what causes the error

storeManagement.load({ params: params });

Store


Ext.define('MyApp.store.ParticipantBoards', {
extend: 'Ext.data.Store',
config: {
model: 'MyApp.model.Participant',
params: {
'grouptype': 1
},
proxy: {
type: 'ajax',
url: 'xhr/xhrStore.asp?cmd=getParticipants',
reader: {
type: 'json',
rootProperty: 'rows'
}
},
autoLoad: true
}
});


Model:


Ext.define('MyApp.model.Participant', {
extend: 'Ext.data.Model',
config: {
fields: [
{ name: 'ID', type: 'int', hidden: true },
{ title: 'Billede', name: 'pic', type: 'string' },
{ title: 'Fornavn', name: 'firstname', type: 'string' },
{ title: 'Efternavn', name: 'lastname', type: 'string' }
]
}
});

mitchellsimoens
2 Feb 2012, 11:31 AM
getParams is a private method but it requires the operation instance to be past in.

msweltzdk
2 Feb 2012, 2:10 PM
So what the error message is basically telling me is, that the function getParams() does not exist or is inaccessible at the time I'm trying to access it?

What would be a better way of going about melting already configured parameters and dynamically added ones together for use?

mitchellsimoens
2 Feb 2012, 2:14 PM
You can use it but you have to pass in the operation instance

msweltzdk
2 Feb 2012, 2:30 PM
I am not sure I get what you're saying completely. Maybe I will when I wake up and get to work tomorrow.

Apart from me doing it wrong, would the approach atleast be right?

msweltzdk
6 Feb 2012, 9:27 AM
Returning back to this issue I still haven't found a solution to actually merging parameters with a proxy that already has parameters.

I would love to see an example of how to do this, if possible.

TommyMaintz
6 Feb 2012, 11:13 AM
Ok, so your goal is to send both the group type param + the cmd param with that request? Try looking for the extraParams configuration on the Proxy.



Ext.define('iBygning.store.ParticipantBoards', {
extend: 'Ext.data.Store',
config: {
model: 'iBygning.model.Participant',
proxy: {
extraParams: {
grouptype: 1
},
type: 'ajax',
url: 'xhr/xhrStore.asp?cmd=getParticipants',
reader: {
type: 'json',
rootProperty: 'rows'
}
},
autoLoad: true
}
});

msweltzdk
6 Feb 2012, 2:04 PM
The main problem I am having with all this is that I have been using Sencha Touch for about 2 weeks now, trying to recover a project that another person made, which isn't really coded that well. It is causing a bunch of confusions.

I have four parameters that need to be passed to the stores proxy as well as the group type parameter. grouptype can of course be put directly on the store but I would like it if I could have the store make a more general call to fetch data, while passing parameters to the store for the more specific calls.

I must be doing something wrong since this is causing me some issues. I'm glad people on this forum are so willing to help.

The specific problem I am having here is trying to call for three different grouptypes to populate three panels in a TabPanel. It seems like a very lengthy and slightly "hacky" way of approaching it from what I have seen so far. I have a hard time believing it has to be this complicated. I can provide code examples for what I have tomorrow when I'm at work again.

TommyMaintz
6 Feb 2012, 2:10 PM
That would be very useful.

msweltzdk
6 Feb 2012, 2:22 PM
I remembered the direct path to the version of the view with controller logic inside of it, so I decided to post it now instead. I know it's long and I'm sorry about that. :) The project is supposed to strictly follow the MVC pattern, and for that reason I am also in the process of getting all the logic refactored into a controller. This is just to show you guys what I'm talking about and to provide the example I'm dealing with.

Don't pay too much attention to the class ux.lm.List it basically does nothing now that I have refactored parts of the project and so on.


Ext.define('iBygning.view.partial.ParticipantsForm', {
extend: 'Ext.TabPanel',
xtype: 'participantsform',
requires: [
'ux.lm.List'
],
config: {
layout: {
type: 'card',
animation: {
type: 'slide',
direction: 'left'
}
},
scrollable: false,
cls: 'sfbform',
defaults: {
layout: 'vbox',
flex: 1,
xtype: 'panel',
iconCls: 'user',
scrollable: false
},
items: [{
title: 'Bestyrelse', //// TAB
items: [{
xtype: 'list', //// LIST
mode: 'MULTI',
config: {
clearSelectionOnDeactivate: true,
cls: 'participantslist',
styleHtmlContent: true,
store: 'ParticipantBoards',
itemSelector: 'div.participantitem',
itemTpl: ['<div class="participantitem">',
'<img src="{pic}" alt="" />',
'<span class="field">{firstname} {lastname}</span>',
'</div>'].join('')
}
}]
}, {
title: 'Ejendomsfunktionærer', //// TAB
items: [{
xtype: 'list', //// LIST
mode: 'MULTI',
config: {
clearSelectionOnDeactivate: true,
cls: 'participantslist',
styleHtmlContent: true,
store: 'ParticipantWorkers',
itemSelector: 'div.participantitem',
itemTpl: ['<div class="participantitem">',
'<img src="{pic}" alt="" />',
'<span class="field">{firstname} {lastname}</span>',
'</div>'].join('')
}
}]
}, {
title: 'Alle', //// TAB
items: [{
xtype: 'list', //// LIST
mode: 'MULTI',
config: {
clearSelectionOnDeactivate: true,
cls: 'participantslist',
id: 'participantsList',
styleHtmlContent: true,
store: 'Participants',
itemSelector: 'div.participantitem',
itemTpl: ['<div class="participantitem">',
'<img src="{pic}" alt="" />',
'<span class="field">{firstname} {lastname}</span>',
'</div>'].join('')
}
}]
}]
},
constructor: function (config) {
if (doTrace) console.log(this.constructor.displayName);
var me = this;

var url = window.location.hash.substring(1).split('/'),
urlWithNoView = window.location.hash.substring(1 + url[0].length).split('/'),
params = { 'Sel': urlWithNoView[0], 'Afd': urlWithNoView[1], 'Afsnit': urlWithNoView[2], 'tdate': urlWithNoView[3] };
//storeWorkers = Ext.getStore('ParticipantWorkers'),
//storeAll = Ext.getStore('Participants');
var storeManagement = Ext.getStore('ParticipantBoards'),
proxyManagement = storeManagement.getProxy();
Ext.apply(params, proxyManagement.getParams());
storeManagement.load({ params: params });

//storeWorkers.load({ params: paramsWorkers });
//storeAll.load({ params: paramsAll });

this.callParent(arguments);
// list1.store.addListener('load',
// function (records) {
// if (records.data.items.length > 0) {
// this.insert(0, tab1);
// //this.setActiveItem(0);
// }
// },
// this
// );
// list2.store.addListener('load',
// function (records) {
// if (records.data.items.length > 0) {
// var insertPos = this.getItems().length > 1 ? 1 : 0;
// this.insert(insertPos, tab2);
// //this.setActiveItem(0);
// }
// },
// this
// );
},
initialize: function () {
if (doTrace) console.log(this.$className + '.initialize');
this.callParent(arguments);
},

/*************************** Custom methods ***************************/
getSelectedParticipants: function () {
return this.getActiveItem().down('list').getSelected().items;
}
});