From ecfee713043345d5958d8ffdc360a06f135c5486 Mon Sep 17 00:00:00 2001 From: legac <renaud.legac@free.fr> Date: Sun, 10 Nov 2013 16:13:45 +0100 Subject: [PATCH] ExtJS 4.2: Activate or inhibit the pagination. --- modules/plugin_dbui/converter.py | 9 +++++++-- modules/plugin_dbui/dbsvc.py | 5 +++-- static/plugin_dbui/src/directstore.js | 8 +++++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/modules/plugin_dbui/converter.py b/modules/plugin_dbui/converter.py index 66ef65af..11325d01 100644 --- a/modules/plugin_dbui/converter.py +++ b/modules/plugin_dbui/converter.py @@ -618,12 +618,16 @@ def to_jsonstore(table, **kwargs): db = table._db tablename = table._tablename - # NOTE: the configuration option baseParams defined the - # transactions parameters seen by the server + # NOTE: the configuration option extraParams defined the + # transactions parameters received by the server. + # # This dictionary contains 3 keys: # tablename: name of the table in the database # dbFields: list of fields which should be red # where: define inner join, mainly to resolve foreign key + # + # NOTE: the keyword pageParam allow to activate / inhibit pagination + # It should be equal ro "page" or undefined respectively. base_params = {'tableName': tablename, 'dbFields': []} cfg = DirectStore(autoLoad=False, @@ -631,6 +635,7 @@ def to_jsonstore(table, **kwargs): extraParams=base_params, idProperty=encode_field(tablename,'id'), model=tablename, + pageParam="", root=ROOT, successProperty=SUCCESS, storeId=get_store_id(tablename), diff --git a/modules/plugin_dbui/dbsvc.py b/modules/plugin_dbui/dbsvc.py index d420e285..b9576873 100644 --- a/modules/plugin_dbui/dbsvc.py +++ b/modules/plugin_dbui/dbsvc.py @@ -617,6 +617,7 @@ class DbSvc(BaseSvc): The transaction data can also contains parameters useful for paging. For more detail see Ext.PagingToolbar: + - page - start - limit - sort @@ -664,9 +665,9 @@ class DbSvc(BaseSvc): elif q_filter and tablename not in db: nrecords = len(db(q_filter).select(db[tablename].id)) - # handle paging options (see Ext.PagingToolbar) + # handle paging options kwargs = {} - if 'start' in arg and 'limit' in arg: + if 'page' in arg: start = int(arg['start']) limit = int(arg['limit']) kwargs['limitby'] = (start, start+limit) diff --git a/static/plugin_dbui/src/directstore.js b/static/plugin_dbui/src/directstore.js index ebfc0468..a3f87055 100644 --- a/static/plugin_dbui/src/directstore.js +++ b/static/plugin_dbui/src/directstore.js @@ -12,6 +12,7 @@ * - **{@link Ext.data.proxy.Direct proxy}** * * - **{@link Ext.data.proxy.Direct#extraParams extraParams}** + * - **{@link Ext.data.proxy.Direct#pageParam pageParam}** * * - **{@link Ext.data.reader.Json JsonReader}** * @@ -45,7 +46,12 @@ Ext.define('App.data.DirectStore', { proxy = { type: 'xdirect' }; - Ext.copyTo(proxy, config, 'extraParams,idProperty,root,successProperty,totalProperty'); + Ext.copyTo(proxy, config, ['extraParams', + 'idProperty', + 'pageParam', + 'root', + 'successProperty', + 'totalProperty']); config.proxy = proxy; } -- GitLab