I use SmartGWT 3.0 power edition
And I try to have following logic
1. to have a combo box "listGridItem" to select the list grid setting
2. and after choose the change the combo box value, it will reload the datasource and fresh the data
3. but I find that after datasource reset and data fetch the previous field level setting is also reset, for example in the following code that I set the empty cell value "--", and it disappear when we change the datasource.
4. also when I want to change the field config and fetch data, it also cannot effective (for example I set the Header hover of the field "units" in my sample code)
Is what we found in 3 and 4 a valid behavior, how can I refresh the data with new field level setting at runtime?
And I try to have following logic
1. to have a combo box "listGridItem" to select the list grid setting
2. and after choose the change the combo box value, it will reload the datasource and fresh the data
3. but I find that after datasource reset and data fetch the previous field level setting is also reset, for example in the following code that I set the empty cell value "--", and it disappear when we change the datasource.
4. also when I want to change the field config and fetch data, it also cannot effective (for example I set the Header hover of the field "units" in my sample code)
Is what we found in 3 and 4 a valid behavior, how can I refresh the data with new field level setting at runtime?
Code:
setSize("100%", "100%"); final VLayout layoutContent = new VLayout(); layoutContent.setSize("100%", "100%"); final ListGrid listGrid = new ListGrid("Item Supply"); listGrid.setDataSource(ItemSupplyXmlDS.getInstance()); final ListGridField itemIdField = new ListGridField("itemID"); final ListGridField itemNameField = new ListGridField("itemName"); final ListGridField skuField = new ListGridField("SKU"); final ListGridField descriptionField = new ListGridField("description"); final ListGridField categoryField = new ListGridField("category"); final ListGridField unitsField = new ListGridField("units"); unitsField.setEmptyCellValue("--"); final ListGridField unitCostField = new ListGridField("unitCost"); final ListGridField inStockField = new ListGridField("inStock"); final ListGridField nextShipmentField = new ListGridField("nextShipment"); final DynamicForm dynamicForm = new DynamicForm(); SelectItem listGridItem = new SelectItem(); listGridItem.setName("listGridType"); listGridItem.setValueMap("Normal", "EmptyTable" , "HeaderHover"); listGridItem.setValue("Normal"); listGridItem.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { String selectedItem = (String) event.getValue(); if ( "Normal".equals( selectedItem ) ) { listGrid.setDataSource(ItemSupplyXmlDS.getInstance()); unitsField.setEmptyCellValue(); listGrid.fetchData(); } else if ( "EmptyTable".equals( selectedItem ) ) { listGrid.setDataSource(ItemSupplyNoRecordDS.getInstance()); listGrid.fetchData(); } else if ( "HeaderHover".equals( selectedItem ) ) { listGrid.setDataSource(ItemSupplyXmlDS.getInstance()); unitsField.setPrompt("<b>Units Value : </b><br>Roll, Ea, Pkt, Set, Tube, Pad, Ream, Tin, Bag, Ctn, Box"); listGrid.fetchData(); } } }); dynamicForm.setFields(listGridItem); listGrid.setFields(itemIdField, itemNameField, skuField, descriptionField, categoryField, unitsField, unitCostField, inStockField, nextShipmentField); listGrid.fetchData(); layoutContent.addMember(dynamicForm); layoutContent.addMember(listGrid); addMember(layoutContent);