Results 1 to 3 of 3

Thread: Restful store with list

  1. #1
    Sencha User
    Join Date
    Aug 2010
    Posts
    177
    Vote Rating
    0
      0  

    Default Restful store with list

    Hello,

    I have a store that consumes data from my restful service that I use with ExtJS4. It works fine but when I try to do that with sencha touch 2.1 list can not consume data.

    Get request seems to be ok, but at browser console there is an extra post request with request payload "{"id":"ext-record-1"}"

    If I use a local store with the servers response list rendered successfully.

    Any help would be great.

    Thanks.
    Code:
    Ext.define('UserItem', {	extend : 'Ext.data.Model',
    	config : {
    		fields : [ 'name', 'surname' ]
    	}
    });
    var store = Ext.create('Ext.data.Store', {
    	model : 'UserItem',
    	autoLoad : true,
    	autoSync : true,
    	proxy : {
    		type : 'rest',
    		url : 'action/users',
    		reader : {
    			type : 'json',
    			root : 'data'
    		},
    		writer : {
    			type : 'json'
    		}
    	}
    });
    var userList = Ext.create('Ext.List', {
    	fullscreen : true,
    	title : 'Users',
    	itemTpl : '<div class="contact">{name} {surname}</div>',
    	store : store
    });
    Note: I want to use common stores in ExtJs and Sencha Touch, I don't think there is a problem with this
    Last edited by mcadirci; 8 Apr 2013 at 4:32 AM. Reason: JS fix
    --
    Mehmet ad?rc?

  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

    In your response, I assume you don't have an id field even if it isn't named id do you?
    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
    Sencha User
    Join Date
    Aug 2010
    Posts
    177
    Vote Rating
    0
      0  

    Default

    Hello,


    I have some other fields and one of them has name id. But I have find a workaround, ExtJS excepts model fields are under:
    Code:
    Ext.define('UserItem', {	extend : 'Ext.data.Model',
    	fields : [ 'name', 'surname' ]
    	});
    But Sencha touch model is
    Code:
    Ext.define('UserItem', {	extend : 'Ext.data.Model',
    	config : {
    		fields : [ 'name', 'surname' ]
    	} });
    So I put fields under both.
    --
    Mehmet ad?rc?

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
  •