Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Mar 2011
    Posts
    10
    Vote Rating
    0
    matteoli is on a distinguished road

      0  

    Question [INFOREQ]api assignment in AjaxProxy

    [INFOREQ]api assignment in AjaxProxy


    Hi,

    I am trying to use the AjaxProxy with the "api" config option to support different store URL's for reading and updating.

    I use it this way:

    Code:
    proxy: {
        type: 'ajax',
        api: {
          read: '/dime_list',
          update: '/dime_update'
        },
        reader: {
          type: 'json',
          root: 'items'
        }
      }
    Reading works well but in case of an update I've got an error: "You are using a ServerProxy but have not supplied it with a url."

    Does anybody know the reason for that behaviour?

    Another confusing thing I have found in the documentation. The doc of the class AjaxProxy (config option "api") says that there are the following actions available "read, create, update, destroy". A paragraph below there are the following actions mentioned "load, create, save, destroy". Which are correct?

    Cheers,
    Oliver

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,049
    Vote Rating
    657
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Can't confirm this on B3 or with the latest code:

    Code:
    Ext.require('Ext.data.*');
    Ext.define('Foo', {
        extend: 'Ext.data.Model',
        fields: ['a']
    });
    Ext.onReady(function(){
        var store = Ext.create('Ext.data.Store', {
            proxy: {
                type: 'ajax',
                api: {
                    read: '/dime_list',
                    update: '/dime_update'
                },
                reader: {
                    type: 'json',
                    root: 'items'
                }
            }
        });
        store.load();
    });
    Please post a test case.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha User
    Join Date
    Mar 2011
    Posts
    10
    Vote Rating
    0
    matteoli is on a distinguished road

      0  

    Default


    In your example you only reading the store. Reading is also possible in my case. The problem occurs on updating the store.

    MVC-like store definition:

    Code:
    Ext.define('GA.store.Dimensions', {
      extend: 'Ext.data.Store',
    
      model: 'GA.model.Dimension',
    
      autoLoad: true,
    
      proxy: {
        type: 'ajax',
        api: {
          read: '/jaavoPaperdocs/frontend/dyn/dime_list',
          update: '/jaavoPaperdocs/frontend/dyn/dime_list'
        },
        reader: {
          type: 'json',
          root: 'items'
        }
      }
      
    });
    MVC-like model definition

    Code:
    Ext.define('GA.model.Dimension', {
      extend: 'Ext.data.Model',
    
      fields: [
        'dime_uid',
        'dime_desc'
      ]
      
    });
    MVC-like controller definition

    Code:
    Ext.define('GA.controller.Dimensions', {
      extend: 'Ext.app.Controller',
      
      stores: ['Dimensions'],
      models: ['Dimension'],
      
      init: function() {
        this.control({
          'dimensionlist': {
            itemdblclick: this.editDimension
          },
          'dimensionedit button[action=save]': {
            click: this.updateDimension
          }
        });
      },
    
      editDimension: function(grid, record) {
        var view = Ext.create('GA.view.dimension.Edit');
        view.down('form').loadRecord(record);
      },
    
      updateDimension: function(button)
      {
        var window = button.up('window');
        form = window.down('form');
        record = form.getRecord();
        values = form.getValues();
        record.set(values);
        window.close();
        this.getStore('Dimensions').sync();
      }
    
    });
    The last line of the updateDimension function should sync the store with the modified record.

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,049
    Vote Rating
    657
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Still can't confirm on b3:

    Code:
    Ext.require('Ext.data.*');
    Ext.define('Foo', {
        extend: 'Ext.data.Model',
        fields: ['a']
    });
    Ext.onReady(function(){
    
        var action = 'update',
            item;
        
        var store = Ext.create('Ext.data.Store', {
            model: 'Foo',
            proxy: {
                type: 'ajax',
                api: {
                    read: 'foo.json?read=true',
                    update: 'foo.json?update=true',
                    create: 'foo.json?create=true',
                    destroy: 'foo.json?destroy=true'
                },
                reader: {
                    type: 'json',
                    root: 'items'
                }
            }
        });
        
        if (action == 'read') {
            store.load();
        } else if (action == 'destroy') {
            item = new Foo({
                a: 'a'
            }, 1);
            store.add(item);
            store.remove(item);
            store.destroy();
        } else if (action == 'create') {
            store.add(new Foo({
                a: 'a'
            }, 1));
            store.create();
        
        } else if (action == 'update') {
            var item = new Foo({
                a: 'b'
            }, 1);
            store.add(item);
            item.set('a', 'c');
            store.save();
            
        }
    });
    If you change the action and refresh you'll see it hits all the correct urls.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  5. #5
    Sencha User
    Join Date
    Oct 2010
    Posts
    11
    Vote Rating
    1
    giovannicandido is on a distinguished road

      0  

    Exclamation I have the same issue

    I have the same issue


    I'am using the api in store:

    Ext.define('ICEISI.ADM.store.Usuarios',{
    extend: 'Ext.data.Store',
    model: 'ICEISI.ADM.model.Usuario',
    autoLoad: true,
    proxy: {
    type: 'ajax',

    api: {
    read: '/gerenciar-usuario/listar/format/json',
    update: '/gerenciar-usuario/atualizar/format/json'
    },
    reader: {
    type: 'json',
    root: 'dados',
    successProperty: 'success'
    }
    }
    });

    And get the issue when update the store: uncaught exception: You are using a ServerProxy but have not supplied it with a url.

    The code that update store is:

    var win = button.up('window'),
    form = win.down('form'),
    record = form.getRecord(),
    values = form.getValues();
    record.set(values);
    this.getStore('Usuarios').sync(); // Here the store is update
    win.close();

    I think this is an Bug

Similar Threads

  1. [2.2] IE 7 Error with cssText assignment
    By nak1 in forum Ext 2.x: Bugs
    Replies: 4
    Last Post: 6 Dec 2012, 3:13 AM
  2. AjaxProxy
    By vmadman in forum Ext: Discussion
    Replies: 4
    Last Post: 9 Aug 2011, 11:27 PM
  3. AjaxProxy on failure
    By h4m1d.r3z4 in forum Sencha Touch 1.x: Discussion
    Replies: 0
    Last Post: 30 Jan 2011, 2:50 AM
  4. Replies: 0
    Last Post: 16 Dec 2010, 2:08 AM

Thread Participants: 2

Tags for this Thread