PDA

View Full Version : Different style tree nodes/items ?



sz_146
19 Jun 2009, 5:44 AM
Is it possible to have differently styled tree items/nodes, using GXT 2 M3 ? Depending on a model's property I would like to give it a different style in the TreePanel.

fother
19 Jun 2009, 5:52 AM
update the css

sz_146
19 Jun 2009, 5:54 AM
How can you do it for different nodes/items in the same tree ?

HerrB
22 Jun 2009, 8:23 AM
See AsyncTreePanelExample using a ModelIconProvider, e.g.:


tree.setIconProvider(new ModelIconProvider<FileModel>() {

public AbstractImagePrototype getIcon(FileModel model) {
if (!(model instanceof FolderModel)) {
String ext = model.getName().substring(model.getName().lastIndexOf(".") + 1);

// new feature, using image paths rather than style names
if ("xml".equals(ext)) {
return IconHelper.createPath("samples/images/icons/page_white_code.png");
} else if ("java".equals(ext)) {
return IconHelper.createPath("samples/images/icons/page_white_cup.png");
} else if ("html".equals(ext)) {
return IconHelper.createPath("samples/images/icons/html.png");
} else {
return IconHelper.createPath("samples/images/icons/page_white.png");
}
}
return null;
}
});

Regards,

HerrB

sz_146
22 Jun 2009, 8:26 AM
I guess this only allows you to change the icons on the nodes. I need to have some of the tree nodes appear blurred/grayed out.

dpope22
5 Oct 2009, 11:07 AM
I have the same issue. I have the need for some of the items in the tree to have highlighting using css. Previously, this was done by applying the css to the individual TreeItems. Is there a way to do this with the new TreePanel?