Results 1 to 4 of 4

Thread: Using the bufferedrenderer render agains a REST API

  1. #1
    Sencha Premium User
    Join Date
    Aug 2016
    Posts
    30

    Default Using the bufferedrenderer render agains a REST API

    I'm trying to use the bufferedrenderer plugin to chunked data in my Ext.grid.Panel component, but I need it to go agains a REST API URL that looks like this http//domain.com/API/REST/ is there a way to change the how the URL is composed.

    RIght now it looks something like this http://localhost:1841/MyDemoApp/reso...t=125&limit=25

    And I want to to look like this http://localhost:1841/REST/API/{PAGE}/{START}/{LIMIT}

    Is that possible?

  2. #2
    Sencha Premium Member
    Join Date
    Jun 2011
    Location
    NL
    Posts
    253
    Answers
    22

    Default

    Yes that's possible by implementing buildUrl(). Here's an example:
    Code:
    Ext.define('MyCustomProxy', {
        extend: 'Ext.data.proxy.Rest',
        alias: 'proxy.mycustomproxy',
    
        buildUrl: function(request) {
            var me = this,
                params = ['page', 'start', 'limit'],
                url = me.getUrl(request);
            
            for (var p in params) {
                url += '/' + request._params[params[p]];
                delete request._params[params[p]];
            }
            me.setUrl(url);
            return me.callParent(arguments);
        } 
    });
    The above code defines a new proxy that extends from Ext.data.proxy.Rest. It will add the page, start and limit params to the url and then delete the original params to prevent the original behaviour. Finally, the original code is called so that other parameters can be added as usual (id, cache buster, filters, sorters).

    To use it, just change the type in your proxy config to refer to the new alias:
    Code:
    proxy: 
    {
       type: 'mycustomproxy',
       url: 'REST/API'        
    }

  3. #3
    Sencha Premium User
    Join Date
    Aug 2016
    Posts
    30

    Default

    Thanks so much for your replay. The only issue I'm having is that Sencha complains that it can't find any function named getUrl(). Is this a custom function?

  4. #4
    Sencha Premium Member
    Join Date
    Jun 2011
    Location
    NL
    Posts
    253
    Answers
    22

    Default

    Here is the Sencha Docs link to getUrl() for Ext JS 6.2.0, and a Fiddle. What version are you using?


Similar Threads

  1. Why is it called REST proxy if it isn't really REST?
    By littlefyr in forum Ext: Discussion
    Replies: 5
    Last Post: 3 Jan 2016, 10:52 PM
  2. [INFOREQ] BufferedRenderer bug?
    By nickd in forum Ext 5: Bugs
    Replies: 1
    Last Post: 24 Mar 2015, 9:52 AM
  3. Need help with BufferedRenderer
    By sarabjeetd in forum Sencha Ext JS Q&A
    Replies: 2
    Last Post: 17 Apr 2014, 7:07 AM
  4. [bug] REST Store bid to Grid do not send REST request
    By holicon_abg in forum Ext 3.x: Bugs
    Replies: 8
    Last Post: 21 Apr 2011, 11:42 PM
  5. contol the cell style agains cell data
    By vStyle in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 3 Oct 2008, 2:05 AM

Tags for this Thread

Posting Permissions

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