问题
Following the discussion in Fetch a specific tag from Rally in order to compute a value in another field I have started rewriting a custom app to extend the Rally's UserStory model to add custom fields to it for easier display and user input. In the success function of the model factory, I use an extend of the model to add my field, but that alone makes the SDK fail with the following error: Uncaught TypeError: Cannot read property 'compile' of undefined
In fact it's not able to instantiate my custom field in the model. Ext.Class.NewClass seems to require a property called tpl (template ?) which is not defined for my custom field. I've tried playing with various properties of the field but without success, I keep on getting the same error.
The stack is as follows:
Ext.define.constructor (sdk-debug.js:81499)
Base.callParent (sdk-debug.js:2894)
Ext.define.constructor (sdk-debug.js:110488)
Ext.Class.newClass (sdk-debug.js:3191)
(anonymous function) (:2)
Ext.ClassManager.instantiate (sdk-debug.js:3951)
Ext.ClassManager.instantiateByAlias (sdk-debug.js:3901)
(anonymous function) (sdk-debug.js:1558)
Ext.define.create (sdk-debug.js:15370)
Ext.define.createComponent (sdk-debug.js:28150)
Ext.define.lookupComponent (sdk-debug.js:28138)
Ext.define.prepareItems (sdk-debug.js:28113)
Ext.define.add (sdk-debug.js:28198)
Ext.define.add (sdk-debug.js:28188)
Ext.define.initItems (sdk-debug.js:28017)
Ext.define.initComponent (sdk-debug.js:28001)
Base.callParent (sdk-debug.js:2894)
Ext.define.initComponent (sdk-debug.js:79700)
Ext.define.constructor (sdk-debug.js:15617)
Base.callParent (sdk-debug.js:2894)
Ext.define.constructor (sdk-debug.js:27106)
Ext.Class.newClass (sdk-debug.js:3191)
(anonymous function) (:2)
Ext.ClassManager.instantiate (sdk-debug.js:3951)
(anonymous function) (sdk-debug.js:1558)
Ext.define.initComponent (sdk-debug.js:77226)
Base.callParent (sdk-debug.js:2894)
Ext.define.initComponent (sdk-debug.js:78944)
Base.callParent (sdk-debug.js:2894)
Ext.define.initComponent (sdk-debug.js:111030)
Ext.define.constructor (sdk-debug.js:15617)
Base.callParent (sdk-debug.js:2894)
Ext.define.constructor (sdk-debug.js:27106)
Base.callParent (sdk-debug.js:2894)
Ext.define.constructor (sdk-debug.js:110959)
Ext.Class.newClass (sdk-debug.js:3191)
(anonymous function) (:2)
Ext.ClassManager.instantiate (sdk-debug.js:3951)
Ext.ClassManager.instantiateByAlias (sdk-debug.js:3901)
(anonymous function) (sdk-debug.js:1558)
Ext.define.create (sdk-debug.js:15370)
Ext.define.createComponent (sdk-debug.js:28150)
Ext.define.lookupComponent (sdk-debug.js:28138)
Ext.define.prepareItems (sdk-debug.js:28113)
Ext.define.add (sdk-debug.js:28198)
Rally.data.ModelFactory.getModel.success (rallytest.html:34) // this is my app call to this.add of the grid
onGetModelsSuccess (sdk-debug.js:106084)
onFetchSuccess (sdk-debug.js:106142)
Ext.define._onTypeDefinitionsRetrieved (sdk-debug.js:106227)
Ext.define._fetchTypeDefinitions.Rally.environment.getIoProvider.httpGet.success (sdk-debug.js:106246)
Ext.apply.callback (sdk-debug.js:5286)
success (sdk-debug.js:105221)
Ext.apply.callback (sdk-debug.js:5286)
Ext.define.handleResponse (sdk-debug.js:53177)
(anonymous function) (sdk-debug.js:1540)
(anonymous function) (TypeDefinition.js:1)
and here is the (current) code:
Ext.define('BVApp', {
extend: 'Rally.app.App',
componentCls: 'app',
layout: {
align: 'stretch'
},
launch: function() {
Rally.data.ModelFactory.getModel({
type: 'UserStory',
success: function(model) {
this.grid = this.add({
xtype: 'rallygrid',
model: Ext.define('BVModel', {
extend: model,
alias : 'BVModel',
fields: [
{name: 'Bv1', type: 'string', persist: false, tpl: 'test',
serialize: function(v, record){ record.data.score = v; },
convert: function(v, record){ return record.data.score; }
}
]
}),
columnCfgs: [
{
text: 'FormattedID', dataIndex: 'FormattedID'
},
{
text: 'ref', dataIndex: 'ref'
},
{
text: 'Name', dataIndex: 'Name', flex: 1
},
{
text: 'Score', dataIndex: 'Score'
}
]
});
}, // end of getModel success
scope: this
});
}
});
回答1:
Solved by calling 2.0p3 SDK instead of the 2.0p2 one.
来源:https://stackoverflow.com/questions/12555812/extending-userstory-model-with-a-custom-field-fails-with-compile-function-not-f