3

i created a Ext.TreePanel and i would have in the node an image, in the text of the node i have the url to the image but i can't load it in the page, i see only the text, there is the possibility to view the image?

this is my code

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,
});

and this is the response of the TreePanel request

[{"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"
}]}]

thank's Luca

4

3 回答 3

1

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

根据 extjs.com 上的 API 文档:

// 在类的配置中指定属性: ... iconCls: 'my-icon'

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

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

[{"text":"comuni","id":"co","leaf":false,"cls":"文件夹","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", "iconCls": "my-icon" }]},{"text":"idrografia" ,"id":"id","leaf":false,"cls":"folder", "iconCls “:”我的图标“} ...等..等...}]

于 2009-07-22T07:41:39.203 回答
0

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

于 2010-03-19T12:30:24.827 回答
0

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

于 2009-07-14T02:21:30.520 回答