我有一些我从服务器获得的数据,根据情况可能带来不同的字段,所以我有这个:
//This is the way i'm attaching the newly created template to the view
//Still no success
function processDataMethod(response){
//some processing here...
var details = Ext.widget('details');
details.config.itemTpl = new Ext.XTemplate(tplFields);
}
Ext.Ajax.request({
url: '...',
...,
success: function (response, request) {
var combinedData = processDataMethod(response);
operation.setResultSet(Ext.create('Ext.data.ResultSet', {
records: combinedData,
total: combinedData.length
}));
operation.setSuccessful();
operation.setCompleted();
if (typeof callback == "function") {
callback.call(scope || that, operation);
currentList.up().push(Ext.widget('details'));
}
}
});
感谢任何帮助,谢谢!!
答案 0 :(得分:1)
你必须区分许多事情:
currentList.up()
返回一个DOM元素(Ext.dom.Element)。这没有方法push()
。Ext.widget('details', config);
,您可以传递{itemTpl: yourTemplate, data: yourData}
之类的配置,以创建包含自定义模板和自定义数据的实例。someWidget.update(data);
。renderTo
选项将组件呈现为HTML元素。这有助于您找到问题吗?