A- Redering of the expand collaps column and icons.
You obviously get a default one being the blue arrows, but you can change these icons or even add other icons that desccribe the type of node you are on…
a- if you just want to change the icons them you can simply overwrite the style in the scss:
.v-foc-gridtree-node-expanded
.v-foc-gridtree-node-collapsed
.v-foc-gridtree-node-leaf
NB: In a future version I should remove the v- as this is reserved to native vaadin components
b- If you want to have a rederer by node type, then you need to set your NodeStyleGenerator that allows you to get your node object and decide on the style you want to apply. In the following example I do so for an object of my own where Bkdn can represent a material, service or role…
getTreeGrid().setNodeStyleGenerator(new IEverproTreeGridNodeStyleGenerator(){
public String getStyleName(Object itemId, String defaultStyleName) {
String style = defaultStyleName;
MyItem item = getTreeGrid().getDataSource().getItem(itemId);
if(item != null){
//Depending on the type of the node we add a string to the style
//which would become something like:
//foc-gridtree-node-expanded-material,...
if(item.isMaterial()){
style += "-material";
}else if(item.isService()){
style += "-service";
}else if(item.isRole()){
style += "-role";
}
}
return style;
}
});
In my case these are the styles that I used
.v-foc-gridtree-node-expanded-material {
border: 0px;
background-image: url("icons/16x16/tree-node-expanded.png"), url("icons/16x16/material.png");
background-position: 0px 0px, 16px 0px;
background-repeat: no-repeat;
background-color: transparent;
height: 20px;
padding-left: 40px;
}
.v-foc-gridtree-node-collapsed-material {
border: 0px;
background-image: url("icons/16x16/tree-node-collapsed.png"), url("icons/16x16/material.png");
background-position: 0px 0px, 16px 0px;
background-repeat: no-repeat;
background-color: transparent;
height: 20px;
padding-left: 40px;
}
.v-foc-gridtree-node-leaf-material {
border: 0px;
background-image: url("icons/tree-node-leaf.png"), url("icons/16x16/material.png");
background-position: 0px 0px, 16px 0px;
background-repeat: no-repeat;
background-color: transparent;
height: 20px;
padding-left: 25px;
}
.v-foc-gridtree-node-expanded-service {
border: 0px;
background-image: url("icons/16x16/tree-node-expanded.png"), url("icons/16x16/service.png");
background-position: 0px 0px, 16px 0px;
background-repeat: no-repeat;
background-color: transparent;
height: 20px;
padding-left: 40px;
}
.v-foc-gridtree-node-collapsed-service {
border: 0px;
background-image: url("icons/16x16/tree-node-collapsed.png"), url("icons/16x16/service.png");
background-position: 0px 0px, 16px 0px;
background-repeat: no-repeat;
background-color: transparent;
height: 20px;
padding-left: 40px;
}
.v-foc-gridtree-node-leaf-service {
border: 0px;
background-image: url("icons/tree-node-leaf.png"), url("icons/16x16/service.png");
background-position: 0px 0px, 16px 0px;
background-repeat: no-repeat;
background-color: transparent;
height: 20px;
padding-left: 25px;
}
.v-foc-gridtree-node-expanded-role {
border: 0px;
background-image: url("icons/16x16/tree-node-expanded.png"), url("icons/16x16/resourcerole.png");
background-position: 0px 0px, 16px 0px;
background-repeat: no-repeat;
background-color: transparent;
height: 20px;
padding-left: 40px;
}
.v-foc-gridtree-node-collapsed-role {
border: 0px;
background-image: url("icons/16x16/tree-node-collapsed.png"), url("icons/16x16/resourcerole.png");
background-position: 0px 0px, 16px 0px;
background-repeat: no-repeat;
background-color: transparent;
height: 20px;
padding-left: 40px;
}
.v-foc-gridtree-node-leaf-role {
border: 0px;
background-image: url("icons/tree-node-leaf.png"), url("icons/16x16/resourcerole.png");
background-position: 0px 0px, 16px 0px;
background-repeat: no-repeat;
background-color: transparent;
height: 20px;
padding-left: 25px;
}
B- Setting the properties twice:
I don’t see the harm in that. Actually in my case it is very rare that one would need to display in the table, or tree all the properties that exist in the datasource, becase the data source would reflec the database content which prctically ends up not matching exactly what I want to show to the user…
C- Sharing the example:
I don’t have an example in my plugin because when I built it I used it in my particular case of DataSource implementation… so if you are doing a simple example I would be grateful if you cn share it on the post, I will include it then in the AddOn