I have tried numerous purmutations to get the setWidth method on my ListGridFields that are part of a Databound ListGrid to work but for some reason 3 of the fields are not being sized correctly.
I have provided all my source code files below - but the piece that attempts to set field widths is just below. I should set all the grid columns to the same length - all but 3 of them are being set that way:
All grid fields are being correctly populated from my database and the developer console is clean of errors except for:
I have provided all my source code files below - but the piece that attempts to set field widths is just below. I should set all the grid columns to the same length - all but 3 of them are being set that way:
Code:
private void gridWidthColumns() { ListGridField[] fields = grid.getAllFields(); for (int i = 0; i < fields.length; i++) { ListGridField field = grid.getField(fields[i].getName()); field.setWidth("*"); } }
Code:
18:05:58.496:INFO:Log:initialized 18:05:58.605:WARN:AutoObserver:Use addInterfaceProperties() to add methods to interface [Class AutoObserver] 18:05:58.792:INFO:Log:isc.Page is loaded
Code:
package com.innotek.vantage.client; import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.widgets.layout.Layout; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.layout.VStack; import com.smartgwt.client.widgets.menu.Menu; import com.smartgwt.client.widgets.menu.MenuBar; import com.smartgwt.client.widgets.menu.MenuItem; import com.smartgwt.client.widgets.menu.events.ClickHandler; import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent; /** * Entry point classes define <code>onModuleLoad()</code>. */ public class Vantage implements EntryPoint { private Globals globals = Globals.getInstance(); private VantageConstants constants = globals.getConstants(); private VLayout vLayout = new VLayout(); private VStack appWin = new VStack(); public Vantage() { } /** * This is the entry point method. */ public void onModuleLoad() { MenuBar menuBar = createMenuBar(); vLayout.setWidth100(); vLayout.setHeight100(); vLayout.addMember(menuBar); vLayout.addMember(appWin); vLayout.draw(); } private MenuBar createMenuBar() { MenuBar menuBar = new MenuBar(); menuBar.setWidth("100%"); menuBar.setStyleName("menubar"); // File Menu Menu menuFile = new Menu(); menuFile.setTitle(constants.MenuFile()); menuFile.setWidth("75"); // Applications Menu Menu menuApplications = new Menu(); menuApplications.setTitle(constants.MenuApplications()); menuApplications.addItem(createMenuItem(constants .MenuApplications_Products(), Applications_Products .getInstance())); menuBar.setMenus(menuFile, menuApplications); return menuBar; } private MenuItem createMenuItem(final String title, final Layout item) { MenuItem menuItem = new MenuItem(title); menuItem.addClickHandler(new ClickHandler() { public void onClick(MenuItemClickEvent event) { if (!appWin.hasMember(item)) { appWin.addMember(item); } item.show(); } }); return menuItem; } }
Code:
package com.innotek.vantage.client; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.types.Side; import com.smartgwt.client.widgets.Window; import com.smartgwt.client.widgets.events.CloseClickHandler; import com.smartgwt.client.widgets.events.CloseClientEvent; import com.smartgwt.client.widgets.layout.Layout; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.tab.Tab; import com.smartgwt.client.widgets.tab.TabSet; public class Applications_Products extends VLayout { static Layout theInstance; static VantageConstants constants = Globals.getInstance().getConstants(); final TabSet tabSet = new TabSet(); private Applications_Products() { super(); tabSet.setTabBarPosition(Side.TOP); tabSet.setWidth100(); tabSet.setHeight100(); // Tab tabAssemblies = createTab(constants.TabProducts_Assemblies()); // Tab tabBulkGlass = createTab(constants.TabProducts_BulkGlass()); Tab tabCartons = createTab(constants.TabProducts_Cartons(), ProductCartonDs.getInstance()); // Tab tabDividers = createTab(constants.TabProducts_Dividers()); // tabSet.addTab(tabAssemblies); // tabSet.addTab(tabBulkGlass); tabSet.addTab(tabCartons); // tabSet.addTab(tabDividers); Window window = new Window(); window.setTitle("Products"); window.setWidth100(); window.setHeight100(); window.setCanDragResize(true); window.addItem(tabSet); window.setShowMinimizeButton(false); window.addCloseClickHandler(new CloseClickHandler() { public void onCloseClick(CloseClientEvent close) { theInstance.hide(); } }); setMembersMargin(10); addMember(window); setWidth100(); setHeight100(); } static public Layout getInstance() { if (theInstance == null) { theInstance = new Applications_Products(); } return theInstance; } private Tab createTab(String title, DataSource datasource) { Tab tab = new Tab(title); final CompoundDbTableEditor editor = new CompoundDbTableEditor(datasource); tab.setPane(editor); return tab; } public void show() { super.show(); Tab tab = tabSet.getSelectedTab(); CompoundDbTableEditor editor = (CompoundDbTableEditor)tab.getPane(); editor.gridHideColumns(); } }
Code:
package com.innotek.vantage.client; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.types.Alignment; import com.smartgwt.client.types.Autofit; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.events.RecordClickEvent; import com.smartgwt.client.widgets.grid.events.RecordClickHandler; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; public class CompoundDbTableEditor extends HLayout { private DataSource datasource; private DynamicForm form = new DynamicForm(); private ListGrid grid = new ListGrid(); private IButton saveButton = new IButton("Save"); public CompoundDbTableEditor(DataSource datasource) { super(); this.datasource = datasource; } public void onInit() { super.onInit(); form.setDataSource(datasource); saveButton.setLayoutAlign(Alignment.CENTER); saveButton.disable(); saveButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { form.saveData(); } }); VLayout editorLayout = new VLayout(5); editorLayout.addMember(form); editorLayout.addMember(saveButton); editorLayout.setWidth(280); grid.setWidth100(); grid.setHeight100(); grid.setDataSource(datasource); grid.setShowResizeBar(true); grid.setAutoFetchData(true); gridWidthColumns(); grid.setAutoFitData(Autofit.HORIZONTAL); grid.addRecordClickHandler(new RecordClickHandler() { public void onRecordClick(RecordClickEvent event) { form.clearErrors(true); form.editRecord(event.getRecord()); saveButton.enable(); } }); addMember(grid); addMember(editorLayout); } public DataSource getDatasource() { return datasource; } public void gridHideColumns() { ListGridField[] fields = grid.getAllFields(); for (int i = 0; i < fields.length; i++) { boolean hide = fields[i].getAttributeAsBoolean("gridHide"); if (hide) { grid.hideField(fields[i].getName()); } } } private void gridWidthColumns() { ListGridField[] fields = grid.getAllFields(); for (int i = 0; i < fields.length; i++) { ListGridField field = grid.getField(fields[i].getName()); field.setWidth("*"); } } }
Code:
package com.innotek.vantage.client; import com.smartgwt.client.data.RestDataSource; import com.smartgwt.client.data.fields.DataSourceIntegerField; import com.smartgwt.client.data.fields.DataSourceTextField; abstract public class ProductDs extends RestDataSource { protected ProductDs(String id) { super(); setID(id); DataSourceTextField prodType = new DataSourceTextField("prodType", "Prod Type", 1, true); prodType.setAttribute("gridHide", false); DataSourceTextField prodMF = new DataSourceTextField("prodMf", "MF id", 2, true); prodMF.setAttribute("gridHide", false); DataSourceTextField prodMFCode = new DataSourceTextField("prodMfCode", "MF Code", 25, true); prodMFCode.setAttribute("gridHide", false); DataSourceTextField prodOther = new DataSourceTextField("prodOther", "Suffix"); prodOther.setAttribute("gridHide", false); DataSourceTextField pk = new DataSourceTextField("pk", "Key", 4); pk.setPrimaryKey(true); pk.setAttribute("gridHide", false); DataSourceTextField prodDesc = new DataSourceTextField("prodDesc", "Description", 80, true); prodDesc.setAttribute("gridHide", false); DataSourceIntegerField custId = new DataSourceIntegerField("custId", "CustId"); custId.setRequired(false); custId.setAttribute("gridHide", true); setFields(prodType, prodMF, prodMFCode, prodOther, pk, prodDesc, custId); } }
Code:
package com.innotek.vantage.client; import com.smartgwt.client.data.fields.DataSourceTextField; public class ProductCartonDs extends ProductDs { private static ProductCartonDs theInstance; private static Globals globals = Globals.getInstance(); public static ProductCartonDs getInstance() { if (theInstance == null) { theInstance = new ProductCartonDs("cartonDS"); } return theInstance; } private ProductCartonDs(String id) { super(id); DataSourceTextField cartonPrint = new DataSourceTextField( "cartonPrint", "Carton Print"); cartonPrint.setAttribute("gridHide", false); DataSourceTextField topFlaps = new DataSourceTextField("topFlaps", "Top Flaps", 3, true); topFlaps.setValueMap("RSC", "AFM"); topFlaps.setAttribute("gridHide", false); DataSourceTextField bottomFlaps = new DataSourceTextField( "bottomFlaps", "Bottom Flaps", 3, true); bottomFlaps.setValueMap("RSC", "AFM"); bottomFlaps.setAttribute("gridHide", false); DataSourceTextField board = new DataSourceTextField("board", "Board"); board.setRequired(true); board.setAttribute("gridHide", false); DataSourceTextField outerLiner = new DataSourceTextField("outerLiner", "Outer Liner"); outerLiner.setRequired(true); outerLiner.setAttribute("gridHide", false); DataSourceTextField innerLiner = new DataSourceTextField("innerLiner", "Inner Liner"); innerLiner.setRequired(true); innerLiner.setAttribute("gridHide", false); DataSourceTextField printType = new DataSourceTextField("printType", "Print Type"); printType.setAttribute("gridHide", true); DataSourceTextField inkColours = new DataSourceTextField("inkColours", "Ink Colours"); inkColours.setRequired(true); inkColours.setAttribute("gridHide", true); DataSourceTextField other = new DataSourceTextField("other", "Other"); other.setRequired(false); other.setAttribute("gridHide", true); setFields(cartonPrint, topFlaps, bottomFlaps, board, outerLiner, innerLiner, printType, inkColours, other); setDataURL(globals.getServerUrl() + "_product_carton_ds.php"); } }
Comment