前言
關鍵字:extjs 3.1 xmltreeloader example error,xmltreeloader 錯誤,treepanel error
原文
http://javarush.com/entry/extjs-xmltreeloader-error
正文
1. 代碼位置:ext3.1\examples\tree\xml-tree-loader.js
2. 注意标紅新增代碼",requestmethod: 'get'"!!

/*!
* ext js library 3.1.0
* copyright(c) 2006-2009 ext js, llc
* http://www.extjs.com/license
*/
//
// extend the xmltreeloader to set some custom treenode attributes specific to our application:
ext.app.bookloader = ext.extend(ext.ux.tree.xmltreeloader, {
processattributes : function(attr){
if(attr.first){ // is it an author node?
// set the node text that will show in the tree since our raw data does not include a text attribute:
attr.text = attr.first + ' ' + attr.last;
// author icon, using the gender flag to choose a specific icon:
attr.iconcls = 'author-' + attr.gender;
// override these values for our folder nodes because we are loading all data at once. if we were
// loading each node asynchronously (the default) we would not want to do this:
attr.loaded = true;
attr.expanded = true;
}
else if(attr.title){ // is it a book node?
attr.text = attr.title + ' (' + attr.published + ')';
// book icon:
attr.iconcls = 'book';
// tell the tree this is a leaf node. this could also be passed as an attribute in the original xml,
// but this example demonstrates that you can control this even when you cannot dictate the format of
// the incoming source xml:
attr.leaf = true;
}
});
ext.onready(function(){
var detailstext = '<i>select a book to see more information...</i>';
var tpl = new ext.template(
'<h2 class="title">{title}</h2>',
'<p><b>published</b>: {published}</p>',
'<p><b>synopsis</b>: {innertext}</p>',
'<p><a href="{url}" target="_blank">purchase from amazon</a></p>'
);
tpl.compile();
new ext.panel({
title: 'reading list',
renderto: 'tree',
layout: 'border',
width: 500,
height: 500,
items: [{
xtype: 'treepanel',
id: 'tree-panel',
region: 'center',
margins: '2 2 0 2',
autoscroll: true,
rootvisible: false,
root: new ext.tree.asynctreenode(),
// our custom treeloader:
loader: new ext.app.bookloader({
dataurl:'xml-tree-data.xml'
,requestmethod: 'get'
}),
listeners: {
'render': function(tp){
tp.getselectionmodel().on('selectionchange', function(tree, node){
var el = ext.getcmp('details-panel').body;
if(node && node.leaf){
tpl.overwrite(el, node.attributes);
}else{
el.update(detailstext);
}
})
}
}
},{
region: 'south',
title: 'book details',
id: 'details-panel',
collapsible: true,
split: true,
margins: '0 2 2 2',
cmargins: '2 2 2 2',
height: 220,
html: detailstext
}]
});

結束語
不要放棄和接受一次失敗的搜尋,不斷的嘗試改變搜尋關鍵字,哪怕是用詞霸翻成英文也得努力去試試,看不懂不要緊,看懂代碼就行,代碼無國界: )
轉載:http://www.cnblogs.com/over140/archive/2010/02/08/1665698.html