0
下面的代碼顯示了樹結構。當我點擊圖片Pic.gif時,它必須被新圖片取代。類似pic1.gif到新圖片,pic6.gif到新圖片。可以幫助mw與代碼它在哪裏適合這個代碼?如何更換圖像?
var children = [{
text: 'family',
icon: 'pic1.gif',
children: [{
text: 'parent1',
icon: 'pic2.gif',
children: [{
icon: 'pic3.gif',
text: 'children1',
leaf: true},
{
icon: 'pic4.gif',
text: 'children2',
leaf: true},
{
icon: 'pic5.gif',
text: 'children3',
leaf: true}]}],
},
{
text: 'Parent2',
icon: 'pic6.gif',
children: [{
icon: 'pic7.gif',
text: 'children4',
leaf: true},
{
icon: 'pic8.gif',
text: 'children5',
leaf: true},
{
icon: 'pic9.gif',
text: "children6",
leaf: true}]}];
Ext.onReady(function() {
var tree = new Ext.tree.TreePanel({
loader: new Ext.tree.TreeLoader(),
width: 1000,
height: 1000,
renderTo: Ext.getBody(),
root: new Ext.tree.AsyncTreeNode({
expanded: false,
leaf: false,
icon: 'pic.gif'
,
text: 'Head',
children: children
})
});
});
你指的是節點何時擴展?即當你點擊pic1.gif節點並顯示了子節點時,你想將pic1.gif交換到別的東西上? – JamesHalsall 2011-03-04 10:53:37
@Jaitsu:確實如此。我需要同樣的東西。 – master123 2011-03-04 11:58:39