1. #1
    Sencha User
    Join Date
    Aug 2010
    Posts
    177
    Vote Rating
    0
    mcadirci is on a distinguished road

      0  

    Default Unanswered: Restful store with list

    Unanswered: 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 - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,327
    Answers
    3540
    Vote Rating
    850
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      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 @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Aug 2010
    Posts
    177
    Vote Rating
    0
    mcadirci is on a distinguished road

      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ı

Thread Participants: 1

Tags for this Thread