Skip to content
Snippets Groups Projects
Commit 6eb57275 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

ExtJS 4.2: Draft version of the "buffered grid" using buffered store.

parent 515c877e
No related branches found
No related tags found
No related merge requests found
""" Collection of tools to help debugging, ....
"""
def fill_categories():
"""Fill the categories table with a large number of data.
Usefull to test the buffered render.
"""
data = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', \
'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y']
for i in range(1, (1000/len(data))+1):
for el in data:
s = el*i
print s
db.categories[0] = dict(code=s, definition=s.lower())
......@@ -17,7 +17,7 @@ dbui.configure_grids(db, plugins=['pGridRowEditorConfirmDelete',
#
gridModifier = dbui.GridModifier('categories')
gridModifier.configure_column('code', width=10)
gridModifier.set_rownumbering(False)
gridModifier.set_rownumbering(True)
gridModifier.append_filter(('code', 'contains', T('bla bla...')))
gridModifier.set_filters(plugins=['pFormToolTip'],
......
......@@ -5,7 +5,14 @@
#-------------------------------------------------------------------------------
#
# teams
# categories (buffered)
#
storeModifier = dbui.StoreModifier('categories')
storeModifier.set_buffered()
#-------------------------------------------------------------------------------
#
# teams (order by)
#
storeModifier = dbui.StoreModifier('teams')
storeModifier.orderby(~db.teams.team)
......@@ -62,5 +62,6 @@ viewportModifier.append_plugins('pViewportLogin')
viewportModifier.configure(logged=True);
viewportModifier.add_node(helpNode, casNode, formNode, gridNode, reportNode)
viewportModifier.default_node(T('Tables'), T('categories'))
# viewportModifier.default_node(T('Tables'), T('new_fields'))
# viewportModifier.default_node(T('Tables'), T('publications'))
viewportModifier.default_node(T('Tables'), 'new_fields')
......@@ -80,7 +80,9 @@ class GridModifier(Modifier):
"""
Modifier.__init__(self, MODIFIER_GRIDS, tablename)
self._tablename = tablename
if 'configure_columns' not in self.data:
self.data.configure_columns = {}
self.data.delete_columns = []
......
......@@ -95,3 +95,37 @@ class StoreModifier(Modifier):
"""
self.data.orderby.extend(fields)
def set_buffered(self, **kwargs):
""" The store is buffered.
The method set the following configuration options:
- autoLoad = False
- buffered = True
- pageSize = 25
- leadingBufferZone = 0
- trailingBufferZone = 0
They can be overwritten using the keyword arguments.
The grid buffering is activate when the store is buffered.
That means that only 5 pages are kept in the cache. Therefore
this is a good option to manipulate almost infinite set of data.
@param kwargs: Any configuration parameter of the C{Ext.data.Store}.
Those related to the buffering are C{buffered}, C{clearOnPaqgeLoad},
C{leadingBufferZone}, C{pageSize}, C{purgePageCount}
and C{trailingBufferZone}.
"""
di = dict(autoLoad=False,
buffered=True,
pageSize=25,
leadingBufferZone=0,
trailingBufferZone=0)
di.update(kwargs)
self.configure(**di)
\ No newline at end of file
......@@ -44,14 +44,18 @@ Ext.define('App.grid.Grid', {
// initialise the base class
this.callParent(arguments);
// load the store if not yet done
// if the grid paging is used load only the first 10 rows
if (!this.store.getTotalCount()) {
if (App.isPlugin(this, 'pGridPaging')) {
this.store.load({params: {start: 0, limit: this.nRows}});
} else {
this.store.load();
}
// consistency check
if (this.store.buffered) {
this.store.getProxy().pageParam = 'page';
}
// load the first page when the buffering is on
if (this.findPlugin('bufferedrenderer')) {
this.store.loadPage(1);
// load the full data set
} else if (!this.store.getTotalCount()) {
this.store.load();
}
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment