For argument's sake, assume I have a 'text' field that contains either a 'true' or 'false' value. I need to represent the string value with a CheckboxItem, and I cannot change the field definition to type='boolean'.
Mostly, this "just works" if I setEditorType. The problem I seem to have is that when the CheckboxItem is rendered, it is always checked.
So if I'm editing a grid record with a field value of "false", the field's editor is opened with my item checked. If I click the checkbox once, the box remains checked and the underlying value is set to true - which is of course correct. Click again to uncheck and set the value to false - also correct. Just that initial state is a problem. Bug?
Here's a little testcase, run with 3.1d20121004 on Firefox 15.1
Mostly, this "just works" if I setEditorType. The problem I seem to have is that when the CheckboxItem is rendered, it is always checked.
So if I'm editing a grid record with a field value of "false", the field's editor is opened with my item checked. If I click the checkbox once, the box remains checked and the underlying value is set to true - which is of course correct. Click again to uncheck and set the value to false - also correct. Just that initial state is a problem. Bug?
Here's a little testcase, run with 3.1d20121004 on Firefox 15.1
Code:
<DataSource ID="ClientOnly"
clientOnly="true"
dataURL="/ds/data/CLientOnly.xml">
<fields>
<field name="id" title="ID" type="int" primaryKey="true"/>
<field name="value" title="Value" type="text" length="3000"/>
</fields>
</DataSource>
Code:
<List>
<ClientOnly>
<id>1</id>
<value>false</value>
</ClientOnly>
</List>
Code:
public void onModuleLoad() {
ListGrid grid = new ListGrid();
grid.setDataSource(DataSource.get("ClientOnly"));
grid.setUseAllDataSourceFields(true);
grid.setAutoFetchData(true);
grid.setCanEdit(true);
ListGridField value = new ListGridField("value");
value.setEditorType(new CheckboxItem());
grid.setFields(value);
VLayout layout = new VLayout();
layout.setWidth100();
layout.setHeight100();
layout.addMember(grid);
layout.draw();
if (!GWT.isScript()) {
KeyIdentifier debugKey = new KeyIdentifier();
debugKey.setCtrlKey(true);
debugKey.setAltKey(true);
debugKey.setKeyName("D");
Page.registerKey(debugKey, new KeyCallback() {
public void execute(String keyName) {
SC.showConsole();
}
});
}
}
Comment