PDA

View Full Version : Ext 4.0.2a MemoryProxy with grouping feature



HTK
19 Aug 2011, 12:04 AM
Hi! I have written simple code for a model with no associations or validations. If I create a store now, which has summary grouping feature and a memory proxy I get an error while adding a new model instance to my store. He throws :
me.summaryGroups[index - 1] is undefined in GroupingSummary.js at printData function. Does anyone know what causes this problem ? It is just simple configuration of model and store. Any suggestions?

raz0r1
19 Aug 2011, 12:14 AM
next time please post a line number and a small example code so someone who wants to help does have less work to find what you meen.

your problem:
it seems like you are not defining any groups in your store:
http://docs.sencha.com/ext-js/4-0/#/api/Ext.data.Store-method-getGroups

HTK
19 Aug 2011, 12:26 AM
Thanks, for your answer. No, that´s of course not my problem. I´ll try to post example code later the day.

HTK
19 Aug 2011, 12:51 AM
Ext.define('WST.model.ReservationItem', {
extend: 'Ext.data.Model',
fields: [
{ name: 'id', type: 'int', useNull: true },
{ name: 'reservationId', type: 'int', useNull: true },
{ name: 'itemId', type: 'int', useNull: true },
{ name: 'itemType', type: 'string', useNull: true },
{ name: 'name', type: 'string' },
{ name: 'personName', type: 'string' },
{ name: 'personNumber', type: 'int', useNull: true },
{ name: 'count', type: 'int' },
{ name: 'price', type: 'float' }
]
});
// grid store
store: Ext.create('Ext.data.Store', {
model: 'WST.model.ReservationItem',
data: [],
proxy: {
type: 'memory',
reader: {
type: 'json'
}
},
groupField: 'personName'
})

for (i = 0; i < 4; i++) {
var record = Ext.create('WST.model.ReservationItem', {
'personName': i
});
store.add(record);
}

I also tried initial data in the store. If I add records in a loop. For example 3 records. The first 2 get added. The last throws the error. And like I said. The error is thrown in GroupingSummary.js on line 162.

Thanks 4 help

raz0r1
19 Aug 2011, 1:52 AM
sorry but it seems like you have an issue anywhere else in your code.
follow works:



<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<link rel="stylesheet" href="extjs/resources/css/ext-all.css" />
<script type="text/javascript" src="extjs/ext-all-debug.js"></script>
<script type="text/javascript">
var store;
Ext.onReady(function(){
Ext.define('WST.model.ReservationItem', {
extend: 'Ext.data.Model',
fields: [
{ name: 'id', type: 'int', useNull: true },
{ name: 'reservationId', type: 'int', useNull: true },
{ name: 'itemId', type: 'int', useNull: true },
{ name: 'itemType', type: 'string', useNull: true },
{ name: 'name', type: 'string' },
{ name: 'personName', type: 'string' },
{ name: 'personNumber', type: 'int', useNull: true },
{ name: 'count', type: 'int' },
{ name: 'price', type: 'float' }
]
});
// grid store
store = Ext.create('Ext.data.Store', {
model: 'WST.model.ReservationItem',
data: [],
proxy: {
type: 'memory',
reader: {
type: 'json'
}
},
groupField: 'personName'
});



for (i = 0; i < 4; i++) {
var record = Ext.create('WST.model.ReservationItem', {
'personName': i
});
store.add(record);




}});</script>
</head>
<body></body>
</html>


after that, execute "store.getGroupData()" in firebug. You get the right output

HTK
19 Aug 2011, 3:22 AM
I´ve found out that my records miss the index property. When I create a JSON Object and add that via store.loadData(record) it works and my records have an index property. I cannot see the reason for that behaviour

raz0r1
19 Aug 2011, 3:59 AM
thats interesting but without more code i could not help anymore.

maybe you can try something like this:


Ext.define('WST.store.ReservationItem', {
model: 'ReservationItem',
.................
});

Ext.create('Ext.grid.Panel', {
store: 'ReservationItem',
.......
});

I am not 100% sure but i think this only works if you have a controller that loads both store and model.

also try using root property of memory proxy.