-
18 Oct 2012 9:14 AM #1
Unanswered: Store rebuid url with parameters
Unanswered: Store rebuid url with parameters
Hello all,
I want to retrieve all parameters of a store to recreate my own uri.
Please take a look of my store :
Url is '/XmlView/ListeArticle', when this store is called, plenty of parameters are sent with it (thanks to POST method).Code:Ext.define('app.store.listeArticleStore', { extend: 'Ext.data.Store', constructor: function(cfg) { var me = this; cfg = cfg || {}; me.callParent([Ext.apply({ storeId: 'listeArticleStore', remoteFilter: true, remoteSort: true, pageSize: 50, proxy: { type: 'ajax', pageParam: 'p', url: '/XmlView/ListeArticle', reader: { type: 'xml', idProperty: 'ART_ID', totalProperty: 'totalProperty', record: 'row' } }, fields: [ {mapping: 'ART_ID', name: 'ART_ID', type: 'int'}, {mapping: 'ART_LIBELLE', name: 'v_art_articles_formats.art_libelle', type: 'string'}, {mapping: 'ART_CODE_ALTIUS', name: 'v_art_articles_formats.art_code_altius', type: 'string'}, {mapping: 'ART_MILLESIME', name: 'v_art_articles_formats.art_millesime', type: 'string'}, {mapping: 'ART_AGE', name: 'v_art_articles_formats.art_age', type: 'string'}, {mapping: 'FOR_CL', name: 'v_art_articles_formats.for_cl', type: 'string'}, {mapping: 'STOCK_PANIERS', name: 'v_art_stock_paniers.stock_paniers', type: 'int'}, {mapping: 'STOCK_RAYON', name: 'v_art_stock_rayon.stock_rayon', type: 'int'}, {mapping: 'STOCK_RESERVE', name: 'v_art_stock_reserve.stock_reserve', type: 'int'}, {mapping: 'STOCK_TOTAL', name: 'v_art_stock_total.stock_total', type: 'int'}, {mapping: 'PRO_ID', name: 'PRO_ID', type: 'int'}, {mapping: 'ART_EN_LIGNE', name: 'ART_EN_LIGNE', type: 'boolean'} ] }, cfg)]); } });
The page parameter named 'p' or a user search named 'my_search' in my application, ....
I would like to rebuild a uri with this parameters thanks to GET method like this example '/XmlView/ListeArticle?p=1&limit=25&my_search=wine&...'
I want to do this to create an excel extract with the same parameters of my gridpanel.
Thanks in advance.
nb: Sorry for my poor english.
-
23 Oct 2012 6:25 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
- Answers
- 3108
Why are you trying to create your own url? THe url can be built auto for you and you can change the param names
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
23 Oct 2012 7:02 AM #3
What he is trying to do is call a different service based on the parameters the store is using.
For example, if he fills his store with:
/xyz/?page=X&start=Y&limit=Z&sort=field1&dir=ASC
He wants to call an Excel export service with the same paremters (probably from an iframe so he can download the excel file without replacing his workspace):
/xyz/export/?page=X&start=Y&limit=Z&sort=field1&dir=ASC&format=excel
To do this you're going to need to do a little work on your own. There is no "store.getParams" function. First if you look at the load function on store you'll see:
That should show you where to get grouping and paging params. The filters and sorters come from the AbstractStore load function:Code:options.groupers = options.groupers || me.groupers.items; options.page = options.page || me.currentPage; options.start = (options.start !== undefined) ? options.start : (options.page - 1) * me.pageSize; options.limit = options.limit || me.pageSize; options.addRecords = options.addRecords || false;
With those you should be able to build an object with the appropriate properties. From there a simple Ext.Object.toQueryString should do.Code:options = Ext.apply({ action: 'read', filters: me.filters.items, sorters: me.getSorters() }, options);


Reply With Quote