Hybrid View
-
16 Jan 2013 7:24 AM #1
BufferedRenderer doesn't work with non-remote data/stores
BufferedRenderer doesn't work with non-remote data/stores
There is a problem with the BufferedRenderer grid's plugin that prevents it from working with data not loaded with a proxy - or at least that's the best way I can summarize it :P
Anyhow, there are 2 scenarios where this can be seen: 1) you directly add records to a store or 2) the store is created dynamically (e.g.) on a hasMany association. Visually the grid will display just a single item and errors will start appearing on the console and the application starts to become instable/buggy.
I've tracked down the problem to the setViewSize method of the BufferedRenderer plugin on the line:
In that line ExtJs is querying the totalCount for the store, however, stores created as I described above, do not have a totalCount set, only a count.Code:end = Math.min(start + viewSize - 1, store.getTotalCount() - 1);
I believe the best solution would be to change that call to something like (store.getTotalCount() || store.getCount()) but I'm unsure of the impact of a larger scale. Anyhow, here's a test case:
Code:<html> <head> <LINK href="http://cdn.sencha.com/ext/beta/4.2.0.265/resources/css/ext-all.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="http://cdn.sencha.com/ext/beta/4.2.0.265/ext-all-dev.js"></script> <script type="text/javascript"> Ext.require('*'); Ext.onReady(function() { Ext.define('User', { extend: 'Ext.data.Model', fields: [{ name: 'name', type: 'string' }] }); var aCommonStore = window.storeRef = new Ext.data.Store({ model: 'User', data: [{ name: 'Foo' }, { name: 'Bar' }] }); new Ext.button.Button({ renderTo: document.body, text: 'Create', handler: function() { new Ext.window.Window({ autoShow: true, layout: 'fit', width: 400, height: 200, items: { xtype: 'gridpanel', plugins: [{ ptype: 'bufferedrenderer' }], store: aCommonStore, columns: [{ dataIndex: 'name', text: 'Name' }] } }); } }); }); </script> </head> </html>
-
16 Jan 2013 11:09 AM #2
This problem also seems to affect filtered stores. The scrollheigt is ajusted to fit the totalCount instead of just the "visible" items.
I've overriden even method of BufferedRenderer that has a getTotalCount() and replaced with getCount(). Everything seems to work fine now.
-
16 Jan 2013 4:05 PM #3
Thanks for the test case, this one has already been resolved post B2.
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
Success! Looks like we've fixed this one. According to our records the fix was applied for
a bug in our system
in
a recent build.


Reply With Quote