我收到错误并尝试跟踪问题。当我将JSONP值替换为内联值时,它运行良好。似乎该程序无法使用模板代码制作html。但到目前为止我无法修复它。有没有人有解决方案?
完整错误跟踪如下:
Uncaught TypeError: Cannot call method 'insertFirst' of null
Ext.define.doAddHeadersencha-touch-all-debug-w-comments.js:62207
Ext.define.findGroupHeaderIndicessencha-touch-all-debug-w-comments.js:62199
Ext.define.doRefreshHeaderssencha-touch-all-debug-w-comments.js:61928
Ext.define.doFiresencha-touch-all-debug-w-comments.js:18703
Ext.define.firesencha-touch-all-debug-w-comments.js:18629
Ext.define.doDispatchEventsencha-touch-all-debug-w-comments.js:25873
Ext.define.dispatchEventsencha-touch-all-debug-w-comments.js:25844
Ext.define.doFireEventsencha-touch-all-debug-w-comments.js:28915
Ext.define.fireEventsencha-touch-all-debug-w-comments.js:28885
Ext.define.loadRecordssencha-touch-all-debug-w-comments.js:38573
Ext.define.onProxyLoadsencha-touch-all-debug-w-comments.js:38239
Ext.define.processResponsesencha-touch-all-debug-w-comments.js:31530
(anonymous function)sencha-touch-all-debug-w-comments.js:31960
Ext.apply.callbacksencha-touch-all-debug-w-comments.js:8877
Ext.define.handleResponsesencha-touch-all-debug-w-comments.js:13916
(anonymous function)sencha-touch-all-debug-w-comments.js:3105
我的源代码和JSONP值如下:
Ext.define("Word", {
extend : "Ext.data.Model",
fields : [ 'id', 'word' ]
});
var xstore = Ext.create('Ext.data.Store', {
model : 'Word',
sorters : 'word',
getGroupString : function(record) {
return record.get('id')[0];
},
proxy : {
type : 'jsonp',
url : 'http://xxx.com/api/index.php/word/all',
extraParams : {
sid : user_storage.user.session_key
},
callbackKey : 'callback',
reader : {
type : 'json',
root : 'data'
}
},
autoLoad : true
});
var groupingBase = {
itemTpl : '<div class="contact2"><strong>{word}</strong>{id}</div>',
mode : 'SINGLE',
allowDeselect : true,
disclosure : true,
grouped : true,
indexBar : true,
onItemDisclosure : {
scope : 'test',
handler : function(record, btn, index) {
alert('Disclose more info for ' + record.get('id'));
}
},
store : xstore
};
var list = Ext.create('Ext.dataview.List', Ext.apply(groupingBase));
list.fullscreen = true;
list.show();
Ext.data.JsonP.callback1({"code":"200","data":[{"id":"1","user_id":"1","glossary_id":"1","word":"dictionary","created_at":"2011-11-14 00:00:00","user_name":"xxxxxx"},{"id":"2","user_id":"1","glossary_id":"1","word":"application","created_at":"2011-11-15 00:00:00","user_name":"xxxxxx"}]})
替换后的源代码如下:
var xstore = Ext.create('Ext.data.Store', {
model : 'Word',
sorters : 'word',
getGroupString : function(record) {
return record.get('id')[0];
},
data : [ {
id : '1',
word : 'Maintz'
}, {
id : '2',
word : 'Spencer'
}, {
id : '3',
word : 'Avins'
} ]
});
谢谢。