当前位置: 首页 > news >正文

ExtJs 3.1 XmlTreeLoader Example Error


前言
  关键字:ExtJs 3.1 XmlTreeLoader Example Error,XmlTreeLoader 错误,TreePanel Error

  ExtJs 3.1的XmlTreeLoader例子折腾了我近一个下午加晚上,官方的例子没有问题,可以加载xml的数据,本地IIS死活不行,也不报错,直接查看官方的代码也是一模一样的,今早意外给让我搜到了,不是在官方,而是在貌似一个韩国的博客里面找到的,致敬一下,本文且做其简单中文"译"本。

 

原文

  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
 * 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 would 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 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 ' ,
            autoScroll: 
true ,
            collapsible: 
true ,
            split: 
true ,
            margins: 
' 0 2 2 2 ' ,
            cmargins: 
' 2 2 2 2 ' ,
            height: 
220 ,
            html: detailsText
        }]
    });
});


   

结束语

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

相关文章:

  • 从一款概念车联想到的分布式系统
  • C# BackGroundWorker控件演示代码
  • 面向接口编程详解(一)——思想基础
  • MSN登陆问题
  • CiSCO 交换机配置 SSH 登陆
  • 飞鸽传书文件传输实现原理
  • dedecms调用全站相关文章怎么设置
  • Golomb及指数哥伦布编码原理介绍及实现
  • @在php中起什么作用?
  • 2017.3.13笔记 this指向
  • 国内又出一个开源网店系统,值得期待...
  • ASP.NET页面解析(3)
  • 2.3 Junit 安装
  • 集成中国
  • JAVA之继承和多态
  • [ JavaScript ] 数据结构与算法 —— 链表
  • 【Amaple教程】5. 插件
  • 【腾讯Bugly干货分享】从0到1打造直播 App
  • 3.7、@ResponseBody 和 @RestController
  • Consul Config 使用Git做版本控制的实现
  • Dubbo 整合 Pinpoint 做分布式服务请求跟踪
  • es6(二):字符串的扩展
  • JavaScript HTML DOM
  • JavaScript 基本功--面试宝典
  • js数组之filter
  • Laravel 实践之路: 数据库迁移与数据填充
  • LeetCode18.四数之和 JavaScript
  • React 快速上手 - 07 前端路由 react-router
  • Theano - 导数
  • Vue 动态创建 component
  • 服务器之间,相同帐号,实现免密钥登录
  • 后端_ThinkPHP5
  • 聚簇索引和非聚簇索引
  • 开源地图数据可视化库——mapnik
  • 前端技术周刊 2018-12-10:前端自动化测试
  • 前端面试总结(at, md)
  • 推荐一款sublime text 3 支持JSX和es201x 代码格式化的插件
  • 好程序员大数据教程Hadoop全分布安装(非HA)
  • $forceUpdate()函数
  • $HTTP_POST_VARS['']和$_POST['']的区别
  • (145)光线追踪距离场柔和阴影
  • (3)(3.5) 遥测无线电区域条例
  • (AngularJS)Angular 控制器之间通信初探
  • (function(){})()的分步解析
  • (八)光盘的挂载与解挂、挂载CentOS镜像、rpm安装软件详细学习笔记
  • (附源码)计算机毕业设计大学生兼职系统
  • (黑马C++)L06 重载与继承
  • (亲测有效)解决windows11无法使用1500000波特率的问题
  • (万字长文)Spring的核心知识尽揽其中
  • (五) 一起学 Unix 环境高级编程 (APUE) 之 进程环境
  • (一)基于IDEA的JAVA基础12
  • (一一四)第九章编程练习
  • (转)Linux下编译安装log4cxx
  • (转)我也是一只IT小小鸟
  • ***详解账号泄露:全球约1亿用户已泄露