天天看点

ExtJs 3.1 XmlTreeLoader Example Error

前言

关键字: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'"!!

ExtJs 3.1 XmlTreeLoader Example Error

/*!

 * ext js library 3.1.0

 * copyright(c) 2006-2009 ext js, llc

 * [email protected]

 * 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

        }]

    });

ExtJs 3.1 XmlTreeLoader Example Error

   

结束语

  不要放弃和接受一次失败的搜索,不断的尝试改变搜索关键字,哪怕是用词霸翻成英文也得努力去试试,看不懂不要紧,看懂代码就行,代码无国界: )

转载:http://www.cnblogs.com/over140/archive/2010/02/08/1665698.html

继续阅读