When I remove a field programmatorically (by using ListGrid.setFields() again, with one field less), and then reordening them (by dragging the columns with the mouse) things go wrong. Essentially only the headers switch but the data columns don't move accordingly.
I tested this on : SC_SNAPSHOT-2011-06-30/PowerEdition Deployment (built 2011-06-30), FireFox 4 with GWT 2.1.0.
Code:
DataSource:
I tested this on : SC_SNAPSHOT-2011-06-30/PowerEdition Deployment (built 2011-06-30), FireFox 4 with GWT 2.1.0.
Code:
Code:
package test.client; import java.util.ArrayList; import java.util.List; import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.DataSourceField; import com.smartgwt.client.widgets.Button; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.layout.VLayout; public class RemoveField implements EntryPoint { private List<ListGridField> listGridFields; private ListGrid listGrid; public void onModuleLoad() { DataSource ds = DataSource.get("contents"); listGridFields = new ArrayList<ListGridField>(); for (DataSourceField field: ds.getFields()) { ListGridField listGridField = new ListGridField(field.getName(), field.getName() + "_Title"); listGridFields.add(listGridField); } listGrid = new ListGrid(); listGrid.setDataSource(ds); listGrid.setFields(listGridFields.toArray(new ListGridField[0])); listGrid.setShowFilterEditor(true); listGrid.setShowHeader(true); listGrid.setAutoFetchData(true); Button button = new Button(); button.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { listGridFields.remove(0); listGrid.setFields(listGridFields.toArray(new ListGridField[0])); } }); VLayout vLayout = new VLayout(); vLayout.addMember(listGrid); vLayout.addMember(button); vLayout.setWidth100(); vLayout.setHeight100(); vLayout.draw(); } }
Code:
<DataSource ID="contents" serverType="sql" tableName="content"> <fields> <field primaryKey="true" type="sequence" name="cntn_pk" hidden="true" export="false"></field> <field title="id" type="text" name="cntn_id"></field> <field title="barcode" type="text" name="cntn_barCode"></field> <field title="Location" type="integer" name="cntn_fk_location"></field> </fields> </DataSource>
Comment