Results 1 to 7 of 7

Thread: Ext.data.proxy.Server.buildUrl(): You are using a ServerProxy but have not supplied i

  1. #1
    Sencha User
    Join Date
    May 2010
    Posts
    151
    Answers
    3

    Default Ext.data.proxy.Server.buildUrl(): You are using a ServerProxy but have not supplied i

    I'm trying to load a simple json struck into a store, but are having problems.....

    Apparently I can't use normal url's with query strings?
    I wan't to use this: /callbacks/scoring_archive/search.php?act=read&uuid=f1d69fbe-8f54-11df-82cf-0050569d2b85&limit=20&page=1

    Now I have this store, which is not working. It's not even trying to load anything, just throwing the error message in the title.

    I understand I can't use uuid as I have in the proxy, but I did it to show what I would like todo.

    Code:
    Ext.define('LiveScoring.store.Search', {
    extend: 'Ext.data.Store',
    
    
        config: {
            storeId: 'Search',
            model: 'LiveScoring.model.Search',
            autoLoad: true,
            
            proxy: {
                type: 'ajax',
                url: '/callbacks/scoring_archive/search.php',
                acation: 'read',
                uuid: 'f1d69fbe-8f54-11df-82cf-0050569d2b85',
                page: 1,
                start: 1,
                limit: 20,
                reader: {
                    type: 'json',
                    root: '',
                    idProperty: 'game_id'
                }
            },
    
    
            listeners: {
                load: function(store, records){
                    console.log('Loaded!');
                }
            }
        }
    });

  2. #2
    Fredric Berling's Avatar
    Join Date
    Sep 2007
    Location
    Sweden
    Posts
    210
    Answers
    4

    Default

    Do not put the proxy inside the config object.

    Code:
    Ext.define('LiveScoring.store.Search', {
            extend: 'Ext.data.Store',
    
            storeId: 'Search',
            model: 'LiveScoring.model.Search',
            autoLoad: true,
            
            proxy: {
                type: 'ajax',
                url: '/callbacks/scoring_archive/search.php',
                acation: 'read',
                uuid: 'f1d69fbe-8f54-11df-82cf-0050569d2b85',
                page: 1,
                start: 1,
                limit: 20,
                reader: {
                    type: 'json',
                    root: '',
                    idProperty: 'game_id'
                }
           },
    
            listeners: {
                    load: function(store, records){
                        console.log('Loaded!');
                    }
            }
        
    });

  3. #3
    Fredric Berling's Avatar
    Join Date
    Sep 2007
    Location
    Sweden
    Posts
    210
    Answers
    4

    Default

    Or even better. Specify the proxy on the model instead.

  4. #4
    Sencha User
    Join Date
    May 2010
    Posts
    151
    Answers
    3

    Default

    Quote Originally Posted by Fredric Berling View Post
    Or even better. Specify the proxy on the model instead.
    Thank you, I'll try that. In Sencha Touch I always have the proxy in the store, but maybe it's different in ExtJS?

    Anyhow, what's the correct way of building url's?

    Page, limit etc. are automatically added, how do I go ahead and add custom parameters?

  5. #5
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791
    Answers
    585

    Default

    If the parameters are fixed then you can add them directly to the url config or use the extraParams config.

    For anything more sophisticated I'd write a custom proxy. Details here:

    http://skirtlesden.com/articles/custom-proxies

  6. #6
    Sencha User
    Join Date
    May 2010
    Posts
    151
    Answers
    3

    Default

    Thanks guys, your recommendations worked!Now, I'm just trying to figure out how to use the Operations object to configure stuff like limit etc.?http://docs.sencha.com/extjs/4.0.7/#...a.OperationHow do I incorporate that in this code?

    Code:
    Ext.define('LiveScoring.model.Search', {
        extend: 'Ext.data.Model',
    
    
    	fields: [
    		{ name: 'id',				type: 'int' },
    		{ name: 'uuid',				type: 'string' },
    		{ name: 'company',			type: 'string' },
    		{ name: 'lanes',			type: 'int' },
    		{ name: 'game_id',			type: 'int' },
    		{ name: 'name',				type: 'string' },
    		{ name: 'team_id',			type: 'int' },
    		{ name: 'group_id',			type: 'int' },
    		{ name: 'team',				type: 'string' },
    		{ name: 'game',				type: 'int' },
    		{ name: 'score',			type: 'int' },			
    		{ name: 'timestamp',		type: 'int' },
    		{ name: 'visitors_current',	type: 'int' },
    		{ name: 'in_pa',			type: 'boolean' }
    	],
    	
    	proxy: {
    		type: 'ajax',
    		url: '/callbacks/scoring_archive/search.php',
            extraParams: {
    			act: 'read',
    			uuid: 'f1d69fbe-8f54-11df-82cf-0050569d2b85',
    			limit: 50
    		},
    		reader: {
    			type: 'json',
    			root: 'games'
    		}
    	}
    });

  7. #7
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791
    Answers
    585

    Default

    I'm not sure I understand the question.

    Usually you'd just call loadPage on the store. That will create an Operation which will be passed to the proxy. Operation is little more than a light-weight wrapper around some standard query options (like paging, sorting, etc.). The proxy is then responsible for mapping those options to a suitable request. The article I mentioned previously explains how to customize that last stage of the process.

    I actually disagree with the advice about moving the proxy onto the model. You should put it where it's appropriate. If you want to use it to load a single model then put it on the model, whereas if you want to load multiple models into a store then you should put it on the store. The proxy on the model is inherited by the store, so in some cases it can be useful to configure the proxy on the model as a default for all of its stores, but I've found that to be rarely useful in practice as different stores usually need slightly different proxies.

Posting Permissions

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