Je travaille sur l'application GWT où je devrais changer les icônes par défaut dans Tree Grid à des icônes de la mienne. Dans d'autres cas, je peux facilement définir des icônes mais ce n'est pas le cas quand j'ai une grille d'arbre. Quand je viens grille par défaut mon code pour l'icône de jeu est comme ceci:Comment définir des icônes dans les colonnes Tree Grid GXT (GWT)?
Protected List<ColumnConfig> getColumns() {
List<ColumnConfig> columnConfigs = new ArrayList<ColumnConfig>();
ColumnConfig columnConfig = new ColumnConfig("status", MSGS.gridUserColumnHeaderStatus(), 50);
GridCellRenderer<GwtUser> setStatusIcon = new GridCellRenderer<GwtUser>() {
public String render(GwtUser gwtUser, String property, ColumnData config, int rowIndex, int colIndex, ListStore<GwtUser> deviceList, Grid<GwtUser> grid) {
KapuaIcon icon;
if (gwtUser.getStatusEnum() != null) {
switch (gwtUser.getStatusEnum()) {
case DISABLED:
icon = new KapuaIcon(IconSet.USER);
icon.setColor(Color.RED);
break;
case ENABLED:
icon = new KapuaIcon(IconSet.USER);
icon.setColor(Color.GREEN);
break;
default:
icon = new KapuaIcon(IconSet.USER);
icon.setColor(Color.GREY);
break;
}
} else {
icon = new KapuaIcon(IconSet.USER);
icon.setColor(Color.GREY);
}
return icon.getInlineHTML();
}
};
columnConfig.setRenderer(setStatusIcon);
columnConfig.setAlignment(HorizontalAlignment.CENTER);
columnConfig.setSortable(false);
columnConfigs.add(columnConfig);
Mais quand je demande que sur mon grille d'arbre puis tout premier élément une icône, et je ne peux pas étendre le réseau. Ceci est mon code actuel pour ce Tree Grid
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
ColumnConfig column = new ColumnConfig("topicName", MSGS.topicInfoTableTopicHeader(), 150);
column.setRenderer(new TreeGridCellRenderer<GwtTopic>());
configs.add(column);
column = new ColumnConfig("timestamp", MSGS.topicInfoTableLastPostedHeader(), 150);
configs.add(column);
store = new TreeStore<GwtTopic>();
AsyncCallback<List<GwtTopic>> topicsCallback = new AsyncCallback<List<GwtTopic>>() {
@Override
public void onSuccess(List<GwtTopic> topics) {
store.add(topics, true);
topicInfoGrid.unmask();
}
@Override
public void onFailure(Throwable t) {
FailureHandler.handle(t);
topicInfoGrid.unmask();
}
};
dataService.findTopicsTree(currentSession.getSelectedAccount().getId(), topicsCallback);
topicInfoGrid = new TreeGrid<GwtTopic>(store, new ColumnModel(configs));
topicInfoGrid.setBorders(false);
topicInfoGrid.setStateful(false);
topicInfoGrid.setLoadMask(true);
topicInfoGrid.mask("Loading");
topicInfoGrid.setStripeRows(true);
topicInfoGrid.getView().setAutoFill(true);
topicInfoGrid.getView().setEmptyText(MSGS.topicInfoGridEmptyText());
topicInfoGrid.disableTextSelection(false);
Comment changer ce code pour pouvoir définir mes propres icônes?
Erreur: Impossible de convertir de convertir de KapuaIcon à AbstractImagePrototype ... – Atenica
Je ne suis pas sûr de ce qui se cache derrière KapuaIcon(), j'ai supposé qu'il s'agissait d'une implémentation de ImageResource. Je suis en train d'éditer ma réponse. – Euclides