PDA

View Full Version : Grid panel data reload problem



amt779
20 Aug 2013, 10:51 PM
I've got the following Ext.data.Store with set Proxy.


opt = {
id : 'some_cur_id'
,model : 'Teci.model.User'
,pageSize : 50
,leadingBufferZone: 50
,proxy_url : 'http://some_path_to_server/?q=some_request'
}

store1 = Ext.create('Ext.data.Store', {
storeId : opt.id,
model : opt.model,
buffered : true,
pageSize : opt.pageSize,
leadingBufferZone: opt.leadingBufferZone,
autoLoad : true,
remoteSort : true,
verticalScroller:{
variableRowHeight: true
},
proxy : Ext.create('Teci.view.InfiniteGridProxy',{
type : 'jsonp',
model : opt.model,
url : opt.proxy_url
})
});

Ext.define('Teci.view.InfiniteGridProxy', {
requires : ['Ext.data.proxy.JsonP'],
extend: 'Ext.data.proxy.JsonP',
type: 'jsonp',
reader: {
root : 'data',
totalProperty : 'total'
},
simpleSortMode: true,
simpleGroupMode: true
});

Ext.define('Teci.model.User', {
extend: 'Ext.data.Model',
fields: [
{ name: 'login', type: 'string' }
,{ name: 'email', type: 'string' }
]
});

I apply this store to the following grid panel


Ext.define('Teci.view.user_data.Grid', {
requires: [
'Ext.grid.*'
,'Ext.data.*'
],
extend: 'Ext.grid.Panel',
columns : [
{
text: 'Login',
dataIndex: 'login',
},{
text: 'E-mail',
dataIndex: 'email',
}]
});

This grid panel is being applied to layout as a tab on a tabPanel by using the folollowing method

...
cmd.makeTab = function(opt){
if(undefined==opt.layout)opt.layout = 'auto';
if( null==Ext.getCmp(opt.id) ){
Ext.getCmp(env.conf.id.view.tabpanel).add(
Ext.create('Teci.view.BasicPanel',{
id : opt.id,
title : opt.title,
iconCls : opt.icon,
layout : opt.layout
})
);
}
Ext.getCmp(env.conf.id.view.tabpanel).setActiveTab(opt.id);
}

...
Ext.define('Teci.view.BasicPanel', {
requires: ['Ext.panel.Panel']
extend: 'Ext.panel.Panel',
closable : true,
header : false,
bodyPadding : 0,
border : false,
frame : true,
autoScroll : true,
style: {
border: 0,
padding:0,
margin: 0
},
margin : '0 0 0 0',
padding : '0 0 0 0'
});

Problems appears when I apply to reload data in my grid. In ordrer to do that I call

Ext.data.StoreManager.lookup('some_cur_id').load();

There're 2 cases when I need to reload my grid data:
1) this method may be called from a Toolbar atteched to the instance of Teci.view.BasicPanel
2) this method may be called from modal window Ext.create('Ext.window.Window',{...})

When I call this method from toolbar it seems to apply correctly. But when I call this method from a modal window or from browser console
1) I get error message
"
TypeError: c is undefined
...(l&&l.label?l.label.getBBox():{width:0,height:0}),w=20,t=10,s=10,r;if(!a.width||...
ext-all.js (line 21)
"
2) The grid panel freezes in Loading... state

This problem appeared in version ext-4.2.1.883
In version ext-4.1.1a I used to get error message, but grid panel data would stil get reloaded.
In version ext-3.x.x there were not such problem
It seems like each newer version contains more bugs than older one. According to my own experience I'd say that the most staible version was 3.6

It seems to me like a huge bug in extJS framework. Could anybody please afford some solution to this problem? How could I call a grid panel data reload method from any gui element I like but not only from the toolbar ?

tjonut
21 Aug 2013, 7:08 AM
Reload function on grid with infinite scroll ( store with buffered) is broken (4.2.1.883). This was reported.

amt779
21 Aug 2013, 11:10 PM
Are there any option to reload my grid somehow? When to expact bugfix?

tjonut
22 Aug 2013, 7:10 AM
maybe this will help



getStoreCount: function(){
var me = this,
count = 0;
if(true === me.isBuffered){
count = me.getTotalCount();
}else{
count = me.getCount();
}
return count;
},


reload: function(options) {
var me = this,
startIdx,
endIdx,
startPage,
endPage,
i,
waitForReload,
bufferZone,
count = me.getStoreCount(),
records;


if (!options) {
options = {};
}


// If buffered, we have to clear the page cache and then
// cache the page range surrounding store's loaded range.
if (me.buffered) {


// So that prefetchPage does not consider the store to be fully loaded if the local count is equal to the total count
delete me.totalCount;


// Clear cache (with initial flag so that any listening BufferedRenderer does not reset to page 1).
me.data.clear(true);


waitForReload = function() {
if (me.rangeCached(startIdx, endIdx)) {
me.loading = false;
me.data.un('pageAdded', waitForReload);
records = me.data.getRange(startIdx, endIdx);
me.fireEvent('load', me, records, true);
}
};
bufferZone = Math.ceil((me.leadingBufferZone + me.trailingBufferZone) / 2);


// Get our record index range in the dataset
if (!me.lastRequestStart) {
startIdx = options.start || 0;


/*
* fix hack for total numebr of records smaller then the page size
*/
endIdx = startIdx + (options.count || ( (me.pageSize < count) ? me.pageSize : count) ) - 1;
// endIdx = startIdx + (options.count || (count ? count : me.pageSize)) - 1;
} else {
startIdx = me.lastRequestStart;
endIdx = me.lastRequestEnd;
}


// Calculate a page range which encompasses the Store's loaded range plus both buffer zones
startPage = me.getPageFromRecordIndex(Math.max(startIdx - bufferZone, 0));
endPage = me.getPageFromRecordIndex(endIdx + bufferZone);


if (me.fireEvent('beforeload', me, options) !== false) {
me.loading = true;


// Wait for the requested range to become available in the page map
// Load the range as soon as the whole range is available
me.data.on('pageAdded', waitForReload);


// Recache the page range which encapsulates our visible records
for (i = startPage; i <= endPage; i++) {
me.prefetchPage(i, options);
}
/*
*FIX/HACK for ExtJS 4.2.1.883
*Empty grids
*/
me.on('prefetch', function(store, records, successful, operation) {
if (records.length === 0) {
me.fireEvent('load', me, records, true);
me.data.un('pageAdded', waitForReload);
}
}, null, {single: true});
}
} else {
return me.callParent(arguments);
}
},

This code work .... in 99 % .... the only case I saw is when you are on the last page .... it loads last page(n) and the next one(n+1)... and when page (n+1) is bring faster then the page n ...it broke the grids..... maybe you have fixes for this case.....

Gary Schlosberg
22 Aug 2013, 12:00 PM
Looks like it's due to be fixed as part of 4.2.2.
http://www.sencha.com/forum/showthread.php?264733

tjonut
22 Aug 2013, 1:31 PM
I will try to use that version.