Results 1 to 3 of 3

Thread: Store rebuid url with parameters

  1. #1
    Sencha User
    Join Date
    Feb 2011
    Posts
    6
    Answers
    1
    Vote Rating
    0
      0  

    Default 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 :
    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)]);
        }
    });
    Url is '/XmlView/ListeArticle', when this store is called, plenty of parameters are sent with it (thanks to POST method).
    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.

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Ext JS Premium Member
    Join Date
    Nov 2009
    Location
    St Louis,MO
    Posts
    267
    Answers
    20
    Vote Rating
    18
      0  

    Default

    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:

    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;
    That should show you where to get grouping and paging params. The filters and sorters come from the AbstractStore load function:

    Code:
            options = Ext.apply({
                action: 'read',
                filters: me.filters.items,
                sorters: me.getSorters()
            }, options);
    With those you should be able to build an object with the appropriate properties. From there a simple Ext.Object.toQueryString should do.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •