Extjs 3.1 xmltreeloader example Error

Source: Internet
Author: User

Preface
Keyword: extjs 3.1 xmltreeloader example error, xmltreeloader error, treepanel Error

The xmltreeloader example of extjs 3.1 tossed me over the last night of addition. The official example is no problem. You can load XML data. If your local IIS does not work, no error is reported. Check the officialCodeThey are exactly the same. This morning, I accidentally found it for me, not in the official website, but in what looks like a Korean blog. I would like to pay tribute to it, this article also provides a simple Chinese "Translation.

Original
Http://javarush.com/entry/ExtJS-XmlTreeLoader-Error

Body

1. Code Location: ext3.1 \ examples \ tree \ xml-tree-loader.js

2. Add code in red", Requestmethod: 'get'"!!

Copy code The Code is as follows :/*!
* Ext JS library 3.1.0
* Copyright (c) 2006-2009 ext JS, LLC
* Licensing@extjs.com
* 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 wocould not want to do this:
ATTR. Loaded = true;
ATTR. Expanded = true;
}
Else if (ATTR. Title) {// is it a book node?

// Set the node text that will show in the tree since our raw data does not include a text attribute:
ATTR. Text = ATTR. Title + '(' + ATTR. Published + ')';

// Book icon:
ATTR. iconcls = 'book ';

// Tell the tree this is a leaf node. This coshould 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
// 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 ('selectionchang', 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 ',
Autoscroll: True,
Collapsible: True,
Split: True,
Margins: '0 2 2 2 ',
Cmargins: '2 2 2 2 ',
Height: 220,
HTML: detailstext
}]
});
});

Conclusion

Do not give up or accept a failed search, and constantly try to change the search keyword. Even if you use the word overlord to translate it into English, you have to try it. It doesn't matter if you don't understand it. You just need to understand the code without Borders :)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.