PDA

View Full Version : [2.0.1] Spans in ModelStringProvider



Cputerace
11 Nov 2009, 8:53 AM
The following code allows us to have the label for a TreePanel item blue and have part of it bold. The problem is if you mouse over the bolded span, it does not think you are moused over the item, so it does not highlight and you cannot click it.


package com.mycompany.gwtprototype.client;

import com.extjs.gxt.ui.client.data.BaseTreeModel;
import com.extjs.gxt.ui.client.data.ModelStringProvider;
import com.extjs.gxt.ui.client.store.TreeStore;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.treepanel.TreePanel;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;

public class GwtPrototype implements EntryPoint {

public void onModuleLoad() {
Viewport v = new Viewport();
RootPanel.get().add(v);
v.setLayout(new FitLayout());
TreePanel<BaseTreeModel> tp = new TreePanel<BaseTreeModel>(new TreeStore<BaseTreeModel>());
tp.setLabelProvider(new ModelStringProvider<BaseTreeModel>(){
public String getStringValue(BaseTreeModel model, String property)
{
return "<span style='color:blue' title='An Item Tooltip'>An Item <span style='font-weight:bold'>(A Bold Span)</span></span>";
}});
tp.getStore().add(new BaseTreeModel(), false);
v.add(tp);
v.layout();
}

}

sven
11 Nov 2009, 8:58 AM
I tested this against latest SVN code and it works without problems.

In TreePanel, findNode you need to change the maxdeepth to be something higher than 4.