Show icon in DataGrid

i’m working with a DataGrid where i want to display a simple icon (from CubaIcon) in a column.
My code is:

 jobTable.addGeneratedColumn("icon", new DataGrid.ColumnGenerator<SchedulerJobTemplate, CubaIcon>( 
        public CubaIcon getValue(DataGrid.ColumnGeneratorEvent<SchedulerJobTemplate> event) {
            return CubaIcon.valueOf(event.getItem().getIcon());

        public Class<CubaIcon> getType() {
            return CubaIcon.class;


The result is:

I’ve tried to debug WebImageRender and also CubaImageRender that seems to find the theme resource … but without correct rendering.

This is how I have done it in the past (sorry for Groovy)

In the init method:
pricesTable.setIconProvider(new CustomIconProvider<Price>())

In the controller

 * An inner class that provides an error icon to the table when the row has an error.
 * Usually we would use an anonymous class but it is confusing constructing 
 * a non static inner class in Groovy.
class CustomIconProvider extends IconProvider<Price>
 public String getItemIcon(Price price) {
 return price.hasError() ? "font-icon:WARNING" : null
1 Like

Many thanks,
i will use this way.


Currently, in order to use CubaIcon as a content of a generated column, you need to implement a custom renderer. I admit that this is inconvenient and I created a GitHub issue.


Thanks Gleb,
at the moment i used a component generated column with a label where i set the icon.
I will change to the new Renderer when will be released.
Kind regards

1 Like

I seen was fixed into 7.0, for 6.10 no correct ? is there workaround to use cuba icon into datagrid ?
setIconProvider is for table not for datagrid

Actually, this issue was implemented for 7.1, since it’s not a bug but a feature. Unfortunately, we have no plans to backport it. Nevertheless, you can use our code as a foundation for your own implementation for 6.10+ version.