PDA

View Full Version : Grid Resize issue



sunnyuser
7 Dec 2010, 12:29 AM
Hi,

I am using the ViewPort as the mainContainer and setting the BorderLayout of this Container. In this ViewPort, I am adding the ContentPanel with collapisble= true option in the West region and one my-defined(TestGrid) widget in the Center region. This TestGrid widget is having one Grid and one FormPanel with some basic components like TextFields, LabelField etc.

My problem is whenever I'm collapsing the WestPanel then grid is not resizing.

My code is looking as :

public class TestApplication implements EntryPoint {

/**
* This is the entry point method.
*/
public void onModuleLoad() {
populateWidget();

}

private void populateWidget() {
Viewport viewPort = new Viewport();
viewPort.setLayout(new BorderLayout());
createWest("West Panel", viewPort);
createCenter(viewPort);
RootPanel.get().add(viewPort);
}

private void createWest(String heading, Viewport viewport) {
BorderLayoutData data = new BorderLayoutData(LayoutRegion.WEST, 275, 325, 475);
data.setMargins(new Margins(0, 0, 5, 5));
data.setCollapsible(true);
data.setSplit(true);

ContentPanel west = new ContentPanel();
west.setBodyBorder(false);
west.setLayoutOnChange(true);
west.setHeading(heading);

viewport.add(west, data);
}

private void createCenter(Viewport viewport) {
LayoutContainer center = new LayoutContainer();
center.setLayout(new FitLayout());

BorderLayoutData data = new BorderLayoutData(LayoutRegion.CENTER);
data.setMargins(new Margins(5, 5, 5, 5));

TestGrid grid = new TestGrid();
center.add(grid);
viewport.add(center, data);
}

}


public class TestGrid extends ContentPanel {

private LayoutContainer area;
private List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
private ColumnModel columnModel;
private ListStore<ModelData> employeeRoleStore = new ListStore<ModelData>();
private EditorGrid<ModelData> empControlGrid;

public TestGrid() {
area = new LayoutContainer();
// area.setLayout(new FitLayout());
createUpperSection(area);
createGridLayout();
createUpperSection(area);
add(area);
}

private void createGridLayout() {
ContentPanel gridContentPanel = new ContentPanel();
gridContentPanel.setSize("100%", "" + 300);
gridContentPanel.setHeaderVisible(true);
gridContentPanel.setFrame(false);
gridContentPanel.setLayout(new FitLayout());
gridContentPanel.setBodyBorder(true);
gridContentPanel.setHeading("Testing Grid");

columnModel = new ColumnModel(columns);

empControlGrid = new EditorGrid<ModelData>(employeeRoleStore, columnModel);
BufferView bufferView = new BufferView();
bufferView.setRowHeight(24);
bufferView.setScrollDelay(10);
bufferView.setCacheSize(10);
empControlGrid.setView(bufferView);
empControlGrid.setBorders(false);
empControlGrid.setStripeRows(true);
empControlGrid.setStyleName("my-x-grid3-row");

gridContentPanel.add(empControlGrid);

area.add(gridContentPanel);
populateGrid();

}

private void populateGrid() {
ColumnConfig nameColumn = new ColumnConfig("personName", "Person Name", 150);
nameColumn.setMenuDisabled(true);
columns.add(nameColumn);
List<String[]> headerNameList = getHeaderNames();
int size = headerNameList == null ? 0 : headerNameList.size();
for (int i = 0; i < size; i++) {
String[] headerNames = headerNameList.get(i);
String headerName = headerNames[1];
String id = headerNames[0];
ColumnConfig headerColumnConfig = new ColumnConfig(id + "_control", "<center>" + headerName + "</center>", 100);
headerColumnConfig.setResizable(false);
headerColumnConfig.setSortable(false);
headerColumnConfig.setMenuDisabled(true);
headerColumnConfig.setAlignment(HorizontalAlignment.CENTER);
columns.add(headerColumnConfig);
}
columnModel = new ColumnModel(columns);
empControlGrid.reconfigure(employeeRoleStore, columnModel);
}

private List<String[]> getHeaderNames() {
int noofHeader = 20;
List<String[]> headerNameList = new ArrayList<String[]>(noofHeader);
for (int i = 0; i < noofHeader; i++) {
String[] headerArray = new String[] { "" + i, "Header Title " + i };
headerNameList.add(headerArray);
}
return headerNameList;
}

private void createUpperSection(LayoutContainer area) {
setBodyBorder(false);
setHeaderVisible(false);
setId("TEST_ID_UPPER_SECTION");
initTopPanel(area);
}

private void initTopPanel(LayoutContainer area) {
FormData formData = new FormData();
final FormPanel panel = new FormPanel();
panel.setFrame(false);
panel.setIconStyle("icon-form");
panel.setCollapsible(false);
panel.setHeaderVisible(false);
panel.setWidth(850);
panel.setBodyBorder(false);
panel.setLayout(new FlowLayout());

LayoutContainer main = new LayoutContainer();
main.setLayout(new ColumnLayout());

LayoutContainer left = new LayoutContainer();

FormLayout layout = new FormLayout();
layout.setLabelAlign(LabelAlign.RIGHT);
layout.setLabelWidth(130);
left.setLayout(layout);

// -----------------------------------------------
// NAME
// -----------------------------------------------
TextField<String> frstNameTxtFld = new TextField<String>();
frstNameTxtFld.setFieldLabel("First Name");
frstNameTxtFld.setAllowBlank(false);
frstNameTxtFld.setWidth(75);
frstNameTxtFld.setAllowBlank(false);

left.add(frstNameTxtFld, formData);

// ///////////// RIGHT /////////////////
LayoutContainer right = new LayoutContainer();
layout = new FormLayout();
layout.setLabelAlign(LabelAlign.RIGHT);
layout.setLabelWidth(170);
right.setLayout(layout);

LabelField fullNameLblFld = new LabelField();
fullNameLblFld.setFieldLabel("Full Name:");
fullNameLblFld.setWidth("50%");

right.add(fullNameLblFld, formData);

LabelField personCodeLblFld = new LabelField();
personCodeLblFld.setFieldLabel("Person Code:");
personCodeLblFld.setWidth("50%");

right.add(personCodeLblFld, formData);

// -----------------------------------------------
// IFOPALs
// -----------------------------------------------
TextField<String> labelLblFld = new TextField<String>();
labelLblFld.setFieldLabel("Label");
labelLblFld.setAllowBlank(true);
labelLblFld.setWidth("126%");

TriggerField<String> text = new TriggerField<String>();
text.setValue("Edit");
text.setEditable(false);
text.setHideTrigger(true);
text.setWidth(35);
text.setBorders(false);

MultiField lineOneMultField = new MultiField();
lineOneMultField.setFieldLabel("Label");
lineOneMultField.setWidth(150);
lineOneMultField.setSpacing(5);
lineOneMultField.add(labelLblFld);
lineOneMultField.add(text);

left.add(lineOneMultField);

main.add(left, new ColumnData(.5));
main.add(right, new ColumnData(.5));

panel.add(main);

area.add(panel);
}
}

Please tell me where I'm dng mistake.

Thanks in Advance !
Sunny User

sven
7 Dec 2010, 1:20 AM
Isnt this the same code you posted in your other thread yesterday and i already corrected there?