-
6 Feb 2012 8:23 AM #1
Answered: Ext.data.Operation Read method problem
Answered: Ext.data.Operation Read method problem
Hi,
I am using a method similar to model.load() and when I try to execute that method, the code breaks inside the Ext.data.Operation processRead method. I get an error saying "typeerror: object is not a function" when trying to execute this code (sencha-touch-all-debug.js):
So for some reason instatiation of Model is not possible. I tried evaluating the expression (new Model) in WebStorm and got the same error message as above ("typeerror: object is not a function")Code:processRead: function(resultSet) { var records = resultSet.getRecords(), processedRecords = [], Model = this.getModel(), ln = records.length, i, record; for (i = 0; i < ln; i++) { record = records[i]; processedRecords.push(new Model(record.data, record.id, record.node)); <--- Breaks here } this.setRecords(processedRecords); return true; },
This is my "load" code and my model:
Model:Code:Ext.define('Intelliplan.Base.Data.Query', { extend: 'Ext.data.Model', execute: function(params, successHandler, scope) { var config = { action: 'read', params: params, model: this }; var operation = Ext.create('Ext.data.Operation', config), proxy = this.getProxy(), record = null, callback; callback = function(operation) { if (operation.wasSuccessful()) { var result; if(proxy.dataType === 'list'){ result = operation.getRecords(); }else{ result = operation.getRecords()[0]; } Ext.callback(successHandler, scope, [result, operation]); }else{ } /* TODO implement handlers for other than success { Ext.callback(config.failure, scope, [record, operation]); } Ext.callback(config.callback, scope, [record, operation]);*/ }; proxy.read(operation, callback, this); } });
So basically my question is: Is this a bug or am I doing something wrong?Code:Ext.define('Intelliplan.Data.System.Session.Query.SessionConfiguration', { extend: 'Intelliplan.Base.Data.Query', config: { idProperty: 'id', proxy: Ext.create('Intelliplan.Base.Proxy.Standard', { url: Intelliplan.Api.BaseUrl + '/System/Session/GetSessionConfiguration' }), fields: [ { name: 'userId' }, { name: 'languageCode' }, { name: 'formats' }, { name: 'calendar' }, { name: 'phrases' }, { name: 'firstName' }, { name: 'surName' }, { name: 'fullName' }, { name: 'userCompanyNo' }, { name: 'userCompanyName' }, { name: 'features' } ] } });
-
Best Answer Posted by TommyMaintz
Try changing this to:
Code:Ext.define('Intelliplan.Base.Data.Query', { extend: 'Ext.data.Model', execute: function(params, successHandler, scope) { var config = { action: 'read', params: params, model: this.self }; var operation = Ext.create('Ext.data.Operation', config) ...
-
6 Feb 2012 11:03 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,641
- Vote Rating
- 434
- Answers
- 3107
What does Model equate to?
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.
-
6 Feb 2012 12:39 PM #3
I'm not at work at the moment, so I can't check for sure, but it's an object (I think it's a model) containing (from what I can remember):
data (contains all the fields defined in the model. Field properties are all empty, as they should be)
node (same, I think)
id: null (not 100% sure about this one)
raw: don't remember
...Some other stuff I can't remember
I realize that this might not be very helpful, so I'll get back to you when I know for sure what Model contains.
-
6 Feb 2012 2:56 PM #4Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Haarlem, Netherlands
- Posts
- 1,235
- Vote Rating
- 4
- Answers
- 28
Try changing this to:
Code:Ext.define('Intelliplan.Base.Data.Query', { extend: 'Ext.data.Model', execute: function(params, successHandler, scope) { var config = { action: 'read', params: params, model: this.self }; var operation = Ext.create('Ext.data.Operation', config) ...
-
7 Feb 2012 12:29 AM #5


Reply With Quote

