PDA

View Full Version : [SOLVED] groupFn in a Grouper and how to use it



WagsMax
17 Feb 2012, 4:33 PM
I have been trying to put a group function into my grouper, and it will not save it. Can someone tell me if it is working? In ST1.1, I had the following config on the Store and it worked:


getGroupString: function(record) {
return (record.get('opnd') === "*" ? "New Calls" : "Opened Calls")
},



How do we do this now in Designer?

aconran
21 Feb 2012, 6:28 PM
I had replied to your other thread here:
http://www.sencha.com/forum/showthread.php?181503-Group-Function-available-yet

But just wanted to provide others links to Jason's example here:
http://www.sencha.com/forum/showthread.php?181391-Build-286-Grouper-still-not-working

WagsMax
21 Feb 2012, 7:29 PM
The example is nice, but it does not show the use of a group function. I need to do something like this:


getGroupString: function(record) {
return (record.get('opnd') === "*" ? "New Calls" : "Opened Calls")
},

and no matter what I do, I cannot save anything that I enter into the groupFn field of a Grouper... it empties it out as soon as I leave the field.

aconran
21 Feb 2012, 8:45 PM
Pasting the anonymous function you posted above into groupFn seems to work properly.



function(record) {
return (record.get('opnd') === "*" ? "New Calls" : "Opened Calls")
}


Is what i pasted in and then clicked away

WagsMax
22 Feb 2012, 8:47 AM
Hi, the function does indeed paste and stay as you said. Now my problem is - it doesn't work. Is "record" being passed to the function internally some how the same way as it was in ST1.1? In ST1.1, I defined the store like this:

App.stores.Getcalls = new Ext.data.Store({
model: 'Getcalls',
autoLoad: true,
getGroupString: function(record) {
return (record.get('opnd') === "*" ? "New Calls" : "Opened Calls")
},
proxy: {
type: 'localstorage',
id: 'fieldcall-calls'
}
});

It doesn't seem to work the same way in Designer???

aconran
22 Feb 2012, 8:57 AM
It doesn't seem to work the same way in Designer???
What does the generated Store and/or Model look like?

WagsMax
22 Feb 2012, 9:00 AM
Here is the store:

Ext.define('App.store.base.Calls', {
extend: 'Ext.data.Store',
requires: [
'App.model.Calls'
],


config: {
autoLoad: true,
model: 'App.model.Calls',
storeId: 'callsStore',
proxy: {
type: 'localstorage',
id: 'fieldcall-calls'
},
grouper: {
id: 'CallsGrouper',
property: 'opnd',
groupFn: function(record) {
return (record.get('opnd') === "*" ? "New Calls" : "Opened Calls")
}
}
}
});

and the model:

Ext.define('App.model.Calls', {
extend: 'Ext.data.Model',
config: {
fields: [
{
name: 'opnd',
type: 'string'
},
{
name: 'call',
type: 'string'
},
{
name: 'link',
type: 'string'
}
]
}
});

aconran
22 Feb 2012, 9:13 AM
Does it throw an error? At first glance it looks right

WagsMax
22 Feb 2012, 9:25 AM
No error... it just does not put the title into the group as per the screen shot below.

jjohnston
22 Feb 2012, 6:27 PM
What happens if you remove the 'property' config from your grouper? It may take precedence over the groupFn.

WagsMax
22 Feb 2012, 6:46 PM
Brilliant! That was it. I can't seem to find the Mark as Best Answer" link sometimes, but that was it.