Hi Isomorphic,
please see this testcase (v10.0p_2015-04-23):
BuiltInDS.java:
employees.ds.xml addition:
I have a similar setup in my application:
Best regards
Blama
please see this testcase (v10.0p_2015-04-23):
BuiltInDS.java:
Code:
package com.smartgwt.sample.client;
import java.util.LinkedHashMap;
import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.core.KeyIdentifier;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.util.PageKeyHandler;
import com.smartgwt.client.util.Page;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.fields.SpinnerItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.layout.VStack;
public class BuiltInDS implements EntryPoint {
private DynamicForm boundForm;
private SelectItem foobar;
private SpinnerItem salary;
private TextItem orgUnit;
private SelectItem gender;
public void onModuleLoad() {
KeyIdentifier debugKey = new KeyIdentifier();
debugKey.setCtrlKey(true);
debugKey.setKeyName("D");
Page.registerKey(debugKey, new PageKeyHandler() {
public void execute(String keyName) {
SC.showConsole();
}
});
VStack vStack = new VStack();
vStack.setLeft(175);
vStack.setTop(75);
vStack.setWidth("70%");
vStack.setMembersMargin(20);
boundForm = new DynamicForm() {
{
setDataSource(DataSource.get("employees"));
setCanEdit(false);
foobar = new SelectItem("GenderCSE");
LinkedHashMap<String, String> hm = new LinkedHashMap<String, String>();
hm.put("F", "Foo");
hm.put("B", "Bar");
hm.put("FB", "Foobar");
foobar.setValueMap(hm);
salary = new SpinnerItem("Salary");
orgUnit = new TextItem("OrgUnit");
gender = new SelectItem("Gender");
setFields(foobar, salary, orgUnit, gender);
}
};
vStack.addMember(boundForm);
vStack.draw();
boundForm.fetchData(new Criteria("EmployeeId", "4"), new DSCallback() {
@Override
public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest) {
foobar.setValue("B");
}
});
}
}
Code:
<field name="GenderCSE" title="GenderCSE" canSave="false" [B]canEdit="true"[/B] customSelectExpression="Gender" />
- The readOnly-setting is dependent on how the form is called.
- The field GenderCSE is never saved (not available as column in the DB), but only a customSelectExpression. Therefore is is defined in .ds.xml as canSave="false" canEdit="true". This is because I have event handlers on it and if I omit the canEdit="true", it is always non-editable because of the canSave="false".
- Now, if I call the DynamicForm with setCanEdit(false) the foobar-SelectItem is enabled nevertheless.
- This makes it possible for the user to use the field and also fire the onChange-event handlers, which I do not want.
- My expectation is that the foobar-field is - like all the other fields - enabled when DynamicForm.setCanEdit(true) and readOnly when DynamicForm.setCanEdit(false).
Best regards
Blama
Comment