【问题标题】:extjs load image in TreePanelextjs 在 TreePanel 中加载图像
【发布时间】:2009-07-13 11:33:11
【问题描述】:

我创建了一个 Ext.TreePanel,我会在节点中有一个图像,在节点的文本中我有图像的 url,但我无法在页面中加载它,我只看到文本,那里可以查看图片吗?

这是我的代码

var root1 = new Tree.AsyncTreeNode({
    text: 'Legenda degli starti PAT',
    draggable:true, // disable root node dragging
    id:'source'
});

var tree1 = new Tree.TreePanel({
    renderTo : 'legend',
    animate:true, 
    loader: new Tree.TreeLoader({dataUrl:'legend.php'}),
    containerScroll: true,
    root: root1,
});

这是 TreePanel 请求的响应

[{"text":"comuni","id":"co","leaf":false,"cls":"folder","children":[{"text":"http:\/\/localhost\
/cgi-bin\/mapserv?map=\/home\/gis\/mapserver\/cartocomune_wms.map&SERVICE=wms&FORMAT=png&VERSION=1.1
.1&LAYER=comuni&REQUEST=GetLegendGraphic","id":"comuni","leaf":true,"cls":"file"}]},{"text":"idrografia"
,"id":"id","leaf":false,"cls":"folder","children":[{"text":"http:\/\/localhost\/cgi-bin\/mapserv
?map=\/home\/gis\/mapserver\/cartocomune_wms.map&SERVICE=wms&FORMAT=png&VERSION=1.1.1&LAYER=idrografia
&REQUEST=GetLegendGraphic","id":"idrografia","leaf":true,"cls":"file"}]},{"text":"viabilita","id":"via"
,"leaf":false,"cls":"folder","children":[{"text":"http:\/\/localhost\/cgi-bin\/mapserv?map=\/home
\/gis\/mapserver\/cartocomune_wms.map&SERVICE=wms&FORMAT=png&VERSION=1.1.1&LAYER=viabilita&REQUEST=GetLegendGraphic"
,"id":"viabilita","leaf":true,"cls":"file"}]},{"text":"uso_suolo","id":"uso","leaf":false,"cls":"folder"
,"children":[{"text":"http:\/\/localhost\/cgi-bin\/mapserv?map=\/home\/gis\/mapserver\/cartocomune_wms
.map&SERVICE=wms&FORMAT=png&VERSION=1.1.1&LAYER=uso_suolo&REQUEST=GetLegendGraphic","id":"uso_suolo"
,"leaf":true,"cls":"file"}]},{"text":"catasto","id":"cat","leaf":false,"cls":"folder","children":[{"text"
:"http:\/\/localhost\/cgi-bin\/mapserv?map=\/home\/gis\/mapserver\/cartocomune_wms.map&SERVICE=wms
&FORMAT=png&VERSION=1.1.1&LAYER=catasto&REQUEST=GetLegendGraphic","id":"catasto","leaf":true,"cls":"file"
}]}]

谢谢 卢卡

【问题讨论】:

    标签: javascript image extjs treepanel


    【解决方案1】:

    您需要在 JSON 中包含节点的“iconCls”属性,该属性引用定义您要为该特定节点显示的图像的 CSS 类。

    根据 extjs.com 上的 API 文档:

    // 在类的配置中指定属性: ... iconCls: '我的图标'

    // 指定用作图标图像的背景图像的 css 类: .my-icon { background-image: url(../images/my-icon.gif) 0 6px no-repeat !important; }

    所以你的 JSON 看起来像这样:

    [{"text":"comuni","id":"co","leaf":false,"cls":"folder","children":[{"text":"http://本地主机\ /cgi-bin/mapserv?map=/home/gis/mapserver/cartocomune_wms.map&SERVICE=wms&FORMAT=png&VERSION=1.1 .1&LAYER=comuni&REQUEST=GetLegendGraphic","id":"comuni","leaf":true,"cls":"file", "iconCls": "my-icon"}]}, {“文本”:“idrografia” ,"id":"id","leaf":false,"cls":"folder", "iconCls": "my-icon"} ...等等..等等... }]

    【讨论】:

      【解决方案2】:

      嗯,不清楚您的问题是什么——您看到图像占位符了吗?如果是这样,您可能需要仔细检查 Ext.BLANK_IMAGE_URL 是否设置正确。如果您尝试加载自定义图像,请检查 Firebug 中呈现的树节点——您的图像标签是否使用正确的 url 正确呈现?还要检查 Firebug 中的“网络”选项卡,看看是否有任何损坏的图像引用。

      【讨论】:

        【解决方案3】:

        确保您的 Ext.BLANK_IMAGE_URL 正确指向 s.gif

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-06-09
          • 2013-07-07
          相关资源
          最近更新 更多