I have problem after updating Smartgwt from 4.1p to 5.0p_2015_02_25 in last versions of FF, IE and Chrome
If I load ListGrid data from datasource, the autofit not succeed in first load.
On the second load the autofit works OK.
Here is small example:
If you click first time to "Set data" button, the autofit does not work. On second click it is OK.
Thanks Pavel
If I load ListGrid data from datasource, the autofit not succeed in first load.
On the second load the autofit works OK.
Here is small example:
If you click first time to "Set data" button, the autofit does not work. On second click it is OK.
Code:
package x.y.z;
import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.AutoFitWidthApproach;
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.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.layout.VLayout;
public class LGTest implements EntryPoint{
@Override
public void onModuleLoad() {
final ListGrid lg = new ListGrid();
lg.setDataSource(new TestDS());
lg.setAutoFitFieldWidths(true);
lg.setAutoFitExpandField("f3");
lg.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
lg.setWidth100();
lg.setHeight100();
lg.setData(new ListGridRecord[]{});
IButton btSetData = new IButton("Set data", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
lg.invalidateCache();
lg.fetchData();
}
});
VLayout vl = new VLayout();
vl.addMember(lg);
vl.addMember(btSetData);
vl.setWidth100();
vl.setHeight100();
vl.draw();
}
public class TestDS extends DataSource {
public TestDS() {
setFields(new DataSourceTextField[]{
new DataSourceTextField("f1", "field 123"),
new DataSourceTextField("f2", "field xyz"),
new DataSourceTextField("f3", " ")
});
setTestData(getData());
setClientOnly(true);
}
}
protected ListGridRecord[] getData() {
ListGridRecord[] recs = new ListGridRecord[10];
for (int i = 0; i< recs.length; i++) {
recs[i] = new ListGridRecord();
recs[i].setAttribute("f1", "ListGridField_1_ListGridRow_" + i);
recs[i].setAttribute("f2", "ListGridField_2_ListGridRow_" + i);
}
return recs;
}
}