Results 1 to 4 of 4

Thread: Bring HttpProxy to call custom URLs

  1. #1

    Default Bring HttpProxy to call custom URLs

    Hello together

    As the title says, I want a HttpProxy, that is attached to a grid with paging and search field, to store and load data using a custom URL. It's configured like this:
    Code:
    proxy: new Ext.data.HttpProxy({
            api: {
                read : 'addresses',
                create : 'addresses/add',
                update: 'addresses/edit',
                destroy: 'addresses/delete'
            },
            doRequest: function(){alert('hallo');}
        })
    Now, the called URL looks like this (requesting page 2 with 25 records on it):
    Code:
    http://test.local/addresses/index?dir=ASC&limit=25&sort=id&start=25
    But I want the called URL to be this:
    Code:
    http://test.local/addresses/index/start:25/sort:id/direction:asc/limit:25
    what do I have to do for this?

    The background is that I want to use the CakePHP Paginator to fetch data from my DB, which then gets passed to my (paging) ExtJS grid using JSON.

    Best
    Dr. Zook

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    The easiest way is probably to call setUrl in the beforeload method.

  3. #3

    Default

    Thanks for this Idea. It works now when I attach the listener to a single proxy directly via init config:
    Code:
    var store = new Ext.data.Store({
        proxy: new Ext.HttpProxy({
            api: {
                read : 'addresses/index',
                create : 'addresses/add',
                update: 'addresses/edit',
                destroy: 'addresses/delete'
            },
            listeners:
            {
                beforeload:function(proxy,params){
                    var page = (params.start / params.limit)+1;
                    var newurl = this.conn.api.read.url;
                    newurl += '/page:'+page+'/limit:'+params.limit+'/sort:'+params.sort+'/direction:'+params.dir;
                    this.setUrl(newurl);
                },
                ...
    Now, I have many stores in my app who need exactly the same functionality. I wanted to create an own CakephpProxy like this:
    Code:
    Ext.ux.CakeProxy = Ext.extend(Ext.data.HttpProxy, {
        initComponent: function(){
            Ext.ux.CakeProxy.superclass.initComponent.apply(this);
            this.on('beforeload',function(proxy,params){
                var page = (params.start / params.limit)+1;
                var newurl = this.conn.api.read.url;
                newurl += '/page:'+page+'/limit:'+params.limit+'/sort:'+params.sort+'/direction:'+params.dir;
                this.setUrl(newurl);
            });
        }
    });
    But when I make a new instance of this extended Class, it doesn't work. What's wrong?
    Code:
    proxy: new Ext.ux.CakeProxy({
            api: {
                read : 'addresses/index',
                create : 'addresses/add',
                update: 'addresses/edit',
                destroy: 'addresses/delete'
            }
    The Proxy gets up and loads data, but keeps using the false url format.

  4. #4
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    HttpProxy is not a component, so it doesn't have an initComponent method! You will need to override the constructor instead.

Similar Threads

  1. Grid data not rendering after successful HttpProxy call? (ASP.NET related?)
    By mvelasquez in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 6 May 2010, 11:56 AM
  2. Replies: 3
    Last Post: 19 May 2009, 8:58 AM
  3. TabPanel, AutoLoad and Custom HttpProxy
    By mcohnen in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 4 Feb 2008, 9:22 AM

Posting Permissions

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