Hi,
There is a editable grid without auto save, so editing multiple rows is possible. The grid's field editorType is ComboBox. Additionally, grid's field displayField is set to other hidden field containing code name as described here: https://www.smartclient.com/smartcli...tionDataSource for performance reasons.
If you run above sample, enter edit mode in the first row and clear Employer field, then go to edit second row - you will see that just cleared value in the first row would be re-applied (but blue marked as modified).
Thanks,
MichalG
ps
SmartClient Version: v12.0p_2018-08-20/LGPL Development Only (built 2018-08-20)
Employment.xml
Department.xml
There is a editable grid without auto save, so editing multiple rows is possible. The grid's field editorType is ComboBox. Additionally, grid's field displayField is set to other hidden field containing code name as described here: https://www.smartclient.com/smartcli...tionDataSource for performance reasons.
Code:
package pl.com.tech4.client; import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.DataSourceField; import com.smartgwt.client.data.OperationBinding; import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.types.DSDataFormat; import com.smartgwt.client.types.DSOperationType; import com.smartgwt.client.types.DSProtocol; import com.smartgwt.client.widgets.form.fields.ComboBoxItem; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; public class MainEntryPoint implements EntryPoint { public void onModuleLoad() { layout(); } private void layout() { DataSource employmentDS = new DataSource(); employmentDS.setID("Employment"); OperationBinding fetchBinding = new OperationBinding(); fetchBinding.setOperationType(DSOperationType.FETCH); fetchBinding.setDataFormat(DSDataFormat.XML); fetchBinding.setDataProtocol(DSProtocol.POSTXML); employmentDS.setOperationBindings(fetchBinding); employmentDS.setDataURL("Employment.xml"); DataSource departmentDS = new DataSource(); departmentDS.setID("Department"); departmentDS.setOperationBindings(fetchBinding); departmentDS.setDataURL("Department.xml"); DataSourceField idDepField = new DataSourceField(); idDepField.setName("id"); idDepField.setPrimaryKey(true); idDepField.setHidden(true); DataSourceTextField codeField = new DataSourceTextField(); codeField.setName("code"); departmentDS.setFields(idDepField, codeField); DataSourceField idField = new DataSourceField(); idField.setName("id"); idField.setPrimaryKey(true); idField.setHidden(true); DataSourceField employerField = new DataSourceField(); employerField.setName("employer"); employerField.setForeignKey("Department.id"); employerField.setValueXPath("employer/id"); ComboBoxItem defaultItem = new ComboBoxItem("employer"); defaultItem.setOptionDataSource(departmentDS); defaultItem.setValueField("id"); defaultItem.setDisplayField("code"); defaultItem.setPickListFields(new ListGridField("id"), new ListGridField("code")); employerField.setEditorProperties(defaultItem); DataSourceTextField employerCodeField = new DataSourceTextField("employer_code"); employerCodeField.setValueXPath("employer/code"); employerCodeField.setHidden(true); employmentDS.setFields(idField, employerField, employerCodeField); ListGridField employerLGF = new ListGridField("employer"); employerLGF.setDisplayField("employer_code"); ListGrid lg = new ListGrid(); lg.setDataSource(employmentDS); lg.setFields(employerLGF); lg.setAutoFetchData(true); lg.setCanEdit(true); lg.setAutoSaveEdits(false); lg.draw(); } }
Thanks,
MichalG
ps
SmartClient Version: v12.0p_2018-08-20/LGPL Development Only (built 2018-08-20)
Employment.xml
Code:
<response> <status>STATUS_SUCCESS</status> <startRow>0</startRow> <endRow>1</endRow> <totalRows>2</totalRows> <data> <Employment> <id>20</id> <employer> <id>3</id> <code>Microsoft</code> </employer> </Employment> <Employment> <id>21</id> <employer> <id>4</id> <code>Apple</code> </employer> </Employment> </data> </response>
Code:
<response> <status>STATUS_SUCCESS</status> <startRow>0</startRow> <endRow>4</endRow> <totalRows>5</totalRows> <data> <Department> <id>1</id> <code>Oracle</code> <parentId> <id>2</id> <code>Sun</code> </parentId> </Department> <Department> <id>2</id> <code>Sun</code> <parentId> <id>2</id> <code>Sun</code> </parentId> </Department> <Department> <id>3</id> <code>Microsoft</code> <parentId> <id>2</id> <code>Sun</code> </parentId> </Department> <Department> <id>4</id> <code>Apple</code> <parentId> <id>2</id> <code>Sun</code> </parentId> </Department> </data> </response>
Comment