PDA

View Full Version : setWidth usage disables display



sylvere
18 Feb 2009, 4:47 PM
Hi,
the following code displays a listview widget within a ContentPanel.
This listview has only one item.


import com.extjs.gxt.ui.client.data.*;
import com.extjs.gxt.ui.client.store.*;
import com.extjs.gxt.ui.client.widget.*;
import com.extjs.gxt.ui.client.widget.layout.*;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.*;

public class App implements EntryPoint {
public void onModuleLoad() {
class foo extends BaseModelData {
public foo(String foo1) {
set("foo1",foo1);
}
}
ContentPanel p = new ContentPanel();
p.setSize(200, 200);
p.setLayout(new AbsoluteLayout());
ListStore<foo> store = new ListStore<foo>();
store.add(new foo("item1"));
ListView<foo> l = new ListView<foo>();
l.setStore(store);
l.setSimpleTemplate("<b>{foo1}</b>");
p.add(l);
RootPanel.get().add(p);
}
}

The following code is almost the same than the one above.
The only difference is written in red: i'm trying to set the width of the listview with the same value than the width of the panel.
In this situation, the listview is not showed anymore.


import com.extjs.gxt.ui.client.data.*;
import com.extjs.gxt.ui.client.store.*;
import com.extjs.gxt.ui.client.widget.*;
import com.extjs.gxt.ui.client.widget.layout.*;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.*;

public class App implements EntryPoint {
public void onModuleLoad() {
class foo extends BaseModelData {
public foo(String foo1) {
set("foo1",foo1);
}
}
ContentPanel p = new ContentPanel();
p.setSize(200, 200);
p.setLayout(new AbsoluteLayout());
ListStore<foo> store = new ListStore<foo>();
store.add(new foo("item1"));
ListView<foo> l = new ListView<foo>();
l.setStore(store);
l.setSimpleTemplate("<b>{foo1}</b>");
p.add(l);
l.setWidth(p.getWidth());
RootPanel.get().add(p);
}
}

Does anyone have an idea ?
I guess this is a rendering issue but i can't find out why.
I use: GXT 1.2.3 and GWT 1.5.3
Thanks.

sylvere
27 Feb 2009, 6:32 AM
Nobody has an idea ?

Thanks.

sylvere
27 Feb 2009, 7:22 AM
I actually fixed it.
I used a FormData when adding my component to the panel.


import com.extjs.gxt.ui.client.data.*;
import com.extjs.gxt.ui.client.store.*;
import com.extjs.gxt.ui.client.widget.*;
import com.extjs.gxt.ui.client.widget.layout.*;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.*;

public class App implements EntryPoint {
public void onModuleLoad() {
class foo extends BaseModelData {
public foo(String foo1) {
set("foo1",foo1);
}
}
ContentPanel p = new ContentPanel();
p.setSize(200, 200);
p.setLayout(new AbsoluteLayout());
ListStore<foo> store = new ListStore<foo>();
store.add(new foo("item1"));
ListView<foo> l = new ListView<foo>();
l.setStore(store);
l.setSimpleTemplate("<b>{foo1}</b>");
p.add(l, new FormData("100%"));
RootPanel.get().add(p);
}
}


But it looks strange to use a FormData with a AbsoluteLayout. I guess that is not the best way to do.
For people interested, FormData is used to provide field layout data w/ FormLayout.