Results 1 to 8 of 8

Thread: Records null in a callback

  1. #1
    Sencha User
    Join Date
    Nov 2009
    Posts
    16
    Vote Rating
    0
      0  

    Exclamation Records null in a callback

    Hello, i've not found this problem elewhere

    I'm creating a store :
    Code:
    monstore = new Ext.extend(Ext.data.JsonStore, {	
    	url: 'munurl',
    	root: 'data',
    	fields: [
    		{name: 'code'},
    		{name: 'name'},
    		{name: 'description'}		
    	],	
    	  	
    	constructor: function(config) {
    		config = config || {};
    		config.fields = config.fields || this.fields;
    		config.root = config.root || this.root;
    		config.totalProperty = config.totalProperty || this.totalProperty;	  
    		
    		monstore .superclass.constructor.call(this, config);
      	}
    });
    I use it and load it. I want to update a Form with the result
    I'm in a Ext.form.FormPanel object

    Code:
    this.store = new monstore();
    this.store.load({
    	params: {
    	     'id': 3219
    	},
       	callback: function(records, options, success){
    		this.getForm().loadRecord(records[0]);		   				
    	},
    	scope: this
    });
    Here is what I get from my url after the load
    Code:
    {"success":true,"data":{"code":"Autovaluation","description":null,"name":"A CUP OF TEA"}}
    The probleme is : Extjs tells me that record is not defined

    record is undefined
    ->this.setValues(record.data);
    Indeed, even the "records" object is null
    I don't understand why. I've got the same configuration on other projets and it works


    Can someone tell me which error I did ?
    Thanks

  2. #2
    Sencha Premium Member steffenk's Avatar
    Join Date
    Jul 2007
    Location
    Haan, Germany
    Posts
    2,676
    Vote Rating
    9
      0  

    Default

    put in a
    Code:
    console.log(arguments);
    in your callback to verify the arguments.
    vg Steffen
    --------------------------------------
    Release Manager of TYPO3 4.5

  3. #3
    Sencha User
    Join Date
    Nov 2009
    Posts
    16
    Vote Rating
    0
      0  

    Default

    Thanks.

    I've added this log and obtains the following arguments

    [[], Object { params={...}, scope={...}}, true]

    so :
    - my records are null
    - the success is "true"
    - the params are what i've put in it, the id.... and some other stuff like scope and so

  4. #4
    Sencha User
    Join Date
    Nov 2009
    Posts
    16
    Vote Rating
    0
      0  

    Default

    Hi, still no answer on my side to solve this problem.
    Does anyone has an hint ??

  5. #5
    Sencha User walldorff's Avatar
    Join Date
    Mar 2008
    Location
    Antwerp, Belgium
    Posts
    165
    Vote Rating
    2
      0  

    Default

    I think the problem may be in "Autovaluation". Escape that character (utf-8) or try without special html characters.
    ExtJS 3.4, WAMP Apache 2.2.17, PHP 5.3.5, MySQL 5.5.8

  6. #6
    Sencha User
    Join Date
    Nov 2009
    Posts
    16
    Vote Rating
    0
      0  

    Default

    hh, I've already tried that, even without accent it doesn't works. Thanks for the idea

    I've just found the solution :

    My store lack the idProperty. If a field of my store is named 'id', it will take it by default (it's my other component which worked). But there is not 'id' field and the store can't find proper dataRecord

    I think there's a lack ok proper error message to show that...

    The solution is to add a 'id' field or to add idProperty: 'code' for my example.

    Thanks

  7. #7
    Sencha User walldorff's Avatar
    Join Date
    Mar 2008
    Location
    Antwerp, Belgium
    Posts
    165
    Vote Rating
    2
      0  

    Default

    I had some experience with special HTML-chars in the json, which became the waterloo of the transaction, so I first thought of that
    Glad you found it
    ExtJS 3.4, WAMP Apache 2.2.17, PHP 5.3.5, MySQL 5.5.8

  8. #8
    Sencha User
    Join Date
    Jul 2008
    Posts
    85
    Vote Rating
    0
      0  

    Default

    data field on the JSON result should be an array, not Object.
    PHP Code:
    {"success":true,"data":[{"code":"Autovaluation","description":null,"name":"A CUP OF TEA"}]} 

Similar Threads

  1. Editing Records and JSON null values
    By geographika in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 10 Mar 2011, 11:56 PM
  2. [FIXED-609] JSONP callback(null) problem
    By aCa in forum Sencha Touch 1.x: Bugs
    Replies: 5
    Last Post: 4 Dec 2010, 5:37 PM
  3. Replies: 13
    Last Post: 31 Mar 2010, 1:11 AM
  4. [Solved] store callback & records count
    By amegahed in forum Ext 3.x: Help & Discussion
    Replies: 18
    Last Post: 16 Jul 2009, 11:18 PM
  5. JsonStore can't get records in load callback
    By paulSC in forum Ext 2.x: Help & Discussion
    Replies: 14
    Last Post: 28 Jun 2009, 8:01 PM

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
  •