前言
  关键字: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
        }]
    });
});

  

结束语

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

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

ExtJs 3.1 XmlTreeLoader Example Error相关推荐

  1. ExtJs 备忘录(3)—— Form表单(三) [ 数据验证 ]

    正文 一.资料 1.1. 表单提示的方式设置,如: Ext.form.Field.prototype.msgTarget='side' 该设置为枚举值:'qtip','side','title','u ...

  2. 前端每周清单第 33 期:React 16 发布与特性介绍,Expo AR 教程,ExtJS 从崛起到沉寂...

    前端每周清单专注前端领域内容,以对外文资料的搜集为主,帮助开发者了解一周前端热点:分为新闻热点.开发教程.工程实践.深度阅读.开源项目.巅峰人生等栏目.欢迎关注[前端之巅]微信公众号(ID:front ...

  3. EXTJS+ASP.NET上传文件带实时进度条代码

    一,文件夹 二,upLoad.cs是继承IHttpModule的类: usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usin ...

  4. 使用ExtJs创建新的UI控件(转)

    组合或扩展 当创建一个新类,往往要作出这么的一个选择:要么拥有某个工具类的实例来扮演首要的角色,要么扩展那个类. 使用ExtJs过程中,推荐从最靠近的基类开始扩展,实现所需的功能即可.这是因为Ext提 ...

  5. ExtJs、ASP.net运用Linq to SQL与SQL储存过程交互

    1 基本要点 1.1 Grid后台分页 1.2 Form表单提交 1.3 前台更新.删除(store.remove).增加(store.insert) 1.4 有webService.aspx.Han ...

  6. extjs中js资源缓存策略

    http的缓存协商 浏览器对静态文件的缓存主要是通过cache-control来控制的,cache-control可以设置no-cache,max-age以及must-revalidate等来设置缓存 ...

  7. PHP+ExtJS 文件上传示例

    xtJS 4 有一个非常方便的文件上传组件,可以用来将文件上传到服务器.本文PHP教程UncleToo将介绍使用PHP和ExtJS实现文件上传功能. 首先,创建文件上传组件Ext.form.Panel ...

  8. extjs学习—-官方模版注释2

    简介:这是extjs学习--官方模版注释2的详细页面,介绍了和javascript,有关的知识.技巧.经验,和一些javascript源码等.这次是一些弹出框.自己将官方的看了几遍,重写了下.其实也差 ...

  9. ExtJS + Gears

    一直对Google的Gears很感兴趣,现在终于有时间尝试一下了,Gears的主要功能如下: LocalServer 在本地缓存和提供应用程序资源(HTML.JavaScript.图片等) : Dat ...

最新文章

  1. P2870 [USACO07DEC]最佳牛线,黄金Best Cow Line, Gold(加强版)(贪心+hash哈希)
  2. (干货)微信小程序转发好友
  3. 浅谈TCP的窗口字段
  4. 小程序云服务器选什么系统好,小程序云服务器操作系统选择
  5. WindowsAPI详解——GetCurrentDirectory 获得程序当前目录
  6. android布局属性详解(转)
  7. Ubuntu18.04上手配置入门指南
  8. adb命令查看手机电量_desired Capabilities和aapt命令查看手机包信息
  9. 便宜可靠的激光雷达可能要来了!Luminar关键部件成本降到3美元
  10. 大学计算机一级准考证打印,河海大学计算机等级考试准考证打印入口
  11. Web聊天室历史记录解决方案(轻喷。。)
  12. jmp怎么做合并的箱线图_基于JMP 15的箱线图(Box Plot)的着色
  13. FPGA之旅设计99例之第十九例----OV5640上电及初始化
  14. python有道自动翻译_python爬虫之有道在线翻译
  15. 高一计算机函数公式,高中全部函数公式大全
  16. 开水团2023届实习笔试
  17. 机器学习案例(三):未来销售预测
  18. Kubernetes priviledge and capabilities
  19. 滚动视差让你不相信“眼见为实”
  20. 基于CUDA的Hough变换并行实现

热门文章

  1. html菜单浮动,浮动菜单,可实现上下滚动的效果
  2. mysql跨服务器查询语句_MySQL 跨服务器访问之-FEDERATED引擎
  3. 【参会指南】神策 2020 数据驱动用户大会,10 月 13 日将重磅开幕!
  4. 「神策客景」全面升级,懂客户,更懂你
  5. Asp.net中网站级异常捕获
  6. Java高级架构之FastDFS分布式文件集群
  7. 几款xshell绝佳配色方案
  8. 适用于WinForm的一个定时器类
  9. git fetch 命令
  10. 揭秘ASP.NET 2.0的Eval方法(转)