ExtJs 3.1 Xmltreeloader Example Error_extjs

Source: Internet
Author: User

Objective
Keywords: ExtJs 3.1 xmltreeloader Example error,xmltreeloader error, Treepanel errors

ExtJs 3.1 Xmltreeloader Example toss me nearly an afternoon plus evening, the official example no problem, can load XML data, local IIS dead and dead, also do not complain, directly to see the official code is exactly the same, this morning accidentally to let me search, Not in the official, but in seemingly a South Korean blog found inside, salute, this article and do its simple Chinese "translation" this.

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

Body

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

2. Note Red Add code ", Requestmethod: ' Get '"!!

Copy Code code 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) {/Are it an author node?

Set the node text that'll show in the tree since we 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 are would not want to does this:
Attr.loaded = true;
Attr.expanded = true;
}
else if (attr.title) {//Is it's it a book node?

Set the node text that'll show in the tree since we raw data does not include a text attribute:
Attr.text = Attr.title + ' (' + attr.published + ') ';

Book icon:
attr.iconcls = ' book ';

Tell the ' tree ' is a leaf node. This could also is passed as an attribute in the original XML,
But this example demonstrates so you can control this even then you cannot dictate the format of
The incoming source XML:
Attr.leaf = true;
}
}
});

Ext.onready (function () {

var detailstext = ' <i>select a book to the more information...</i> ';

var TPL = new Ext.template (
'

' <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 ',
Autoscroll:true,
Collapsible:true,
Split:true,
Margins: ' 0 2 2 2 ',
Cmargins: ' 2 2 2 2 ',
height:220,
Html:detailstext
}]
});
});


concluding remarks

Do not give up and accept a failure of the search, and constantly try to change the search keyword, even if the word pa turned into English also have to try hard, do not understand does not matter, read the code on the line, 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.