PDA

View Full Version : [CLOSED] Conceptual bug in method "getRejectRecords" of a buffered store in ExtJS 4.2.0



ElCondor1969
23 Apr 2013, 5:01 AM
Hi to all.
The current implementation of getRejectRecords in ExtJS 4.2.0 is:

getRejectRecords: function() {
// Return phantom records + updated records
return Ext.Array.push(this.data.filterBy(this.filterNewOnly).items, this.getUpdatedRecords());

If the store is buffered, this.data is a PageMap object and not a Mixed Collection object. While mixed collections have filterBy method, PageMap not. So, when you invoke the rejectChanges store method, who calls getRejectRecords method, if the store is buffered you get an exception, as I have experienced always in my proofs.
I am at your disposal for any clarification.
Bye!

Sergio.

*EDIT BY SLEMMON
Tested in 4.2.0
Tested in 4.2.1.762


Ext.define('ForumThread', {
extend: 'Ext.data.Model',
fields: [
'title', 'forumtitle', 'forumid', 'username', {
name: 'replycount',
type: 'int'
}, {
name: 'lastpost',
mapping: 'lastpost',
type: 'date',
dateFormat: 'timestamp'
},
'lastposter', 'excerpt', 'threadid'
],
idProperty: 'threadid'
});


// create the Data Store
var store = Ext.create('Ext.data.Store', {
id: 'store',
model: 'ForumThread',
remoteGroup: true,
// allow the grid to interact with the paging scroller by buffering
buffered: true,
leadingBufferZone: 300,
pageSize: 100,
proxy: {
// load using script tags for cross domain, if the data in on the same domain as
// this page, an Ajax proxy would be better
type: 'jsonp',
url: 'http://www.sencha.com/forum/remote_topics/index.php',
reader: {
root: 'topics',
totalProperty: 'totalCount'
},
// sends single sort as multi parameter
simpleSortMode: true,
// sends single group as multi parameter
simpleGroupMode: true,


// This particular service cannot sort on more than one field, so grouping === sorting.
groupParam: 'sort',
groupDirectionParam: 'dir'
},
sorters: [{
property: 'threadid',
direction: 'ASC'
}],
autoLoad: true,
listeners: {


// This particular service cannot sort on more than one field, so if grouped, disable sorting
groupchange: function(store, groupers) {
var sortable = !store.isGrouped(),
headers = grid.headerCt.getVisibleGridColumns(),
i, len = headers.length;

for (i = 0; i < len; i++) {
headers[i].sortable = (headers[i].sortable !== undefined) ? headers[i].sortable : sortable;
}
},


// This particular service cannot sort on more than one field, so if grouped, disable sorting
beforeprefetch: function(store, operation) {
if (operation.groupers && operation.groupers.length) {
delete operation.sorters;
}
}
}
});


function renderTopic(value, p, record) {
return Ext.String.format(
'<a href="http://sencha.com/forum/showthread.php?t={2}" target="_blank">{0}</a>',
value,
record.data.forumtitle,
record.getId(),
record.data.forumid
);
}


var grid = Ext.create('Ext.grid.Panel', {
width: 700,
height: 500,
collapsible: true,
title: 'ExtJS.com - Browse Forums',
store: store,
loadMask: true,
plugins: {
ptype: 'cellediting'
},
tbar: [{
text: 'Reject Changes'
, handler: function () {
grid.getStore().rejectChanges();
}
}],
selModel: {
pruneRemoved: false
},
multiSelect: true,
viewConfig: {
trackOver: false
},
features:[{
ftype: 'grouping',
hideGroupedHeader: false
}],
// grid columns
columns:[{
xtype: 'rownumberer',
width: 50,
sortable: false
},{
tdCls: 'x-grid-cell-topic',
text: "Topic",
dataIndex: 'title',
flex: 1,
renderer: renderTopic,
sortable: true
},{
text: "Author",
dataIndex: 'username',
width: 100,
hidden: true,
sortable: true
},{
text: "Replies",
dataIndex: 'replycount',
align: 'center',
width: 70,
sortable: false,
editor: {
xtype: 'numberfield'
}
},{
id: 'last',
text: "Last Post",
dataIndex: 'lastpost',
width: 130,
renderer: Ext.util.Format.dateRenderer('n/j/Y g:i A'),
sortable: true,
groupable: false
}],
renderTo: Ext.getBody()
});

slemmon
23 Apr 2013, 9:08 AM
Thanks for the report! I have opened a bug in our bug tracker.

UGA_Zimma
1 May 2013, 10:42 AM
This seems to be a recurring theme. I get the same conflict when I call store.sync() on a buffered store.

Is this a different bug or just another case of PageMap vs MixedCollection?

Thanks,

UGA_Zimma

chge
28 May 2013, 2:13 AM
There are some methods in Ext.data.Store (Ext JS 4.2.1) which reference "this.data.items" and trying to iterate over them.

Grouping:


constructGroups
getGroups
getGroupData
updateGroupsOnUpdate


And some other:


each
clearData
sum
min
max
average
aggregate


Ext.data.PageMap (this.data) doesn't have such property, but have some methods to iterate over records. It seems that implementation of Ext.data.Store should use them instead (when possible).