Hi isomorphic,
I have a SelectItem with multiple rows. I noticed that a row is removed after sorting by the DisplayField and some updateData call.
Code levels used:
SmartClient Version: "v12.1p_2023-10-21/Pro Deployment"
Here is the code and steps to reproduce it:
Code:
Steps:
1. Expand the SelectItem.

2. Sort by Name.

3. Select option "xyz".
4. Click the "update_xyz" button. >>> this will update the "xyz" option to "xyz - updated"
5. Expand the SelectItem.

6. Sort by Name.

7. Select option "abc".
8. Click the "update_abc" button. >>> this will update the abc option to "abc - updated"
9. Expand the SelectItem.

There are duplicate "--NONE--"options and the "xyz - updated" option is removed from the list.
I have a SelectItem with multiple rows. I noticed that a row is removed after sorting by the DisplayField and some updateData call.
Code levels used:
SmartClient Version: "v12.1p_2023-10-21/Pro Deployment"
Here is the code and steps to reproduce it:
Code:
Code:
public class Sandbox1 implements EntryPoint {
private static final String ID = "id";
private static final String VISIBILITY = "visibility";
private static final String NAME = "name";
private static final String ABC_ID = "abc_id";
private static final String LMN_ID = "lmn_id";
private static final String XYZ_ID = "xyz_id";
private static final String ABC_NANE = "abc";
private static final String LMN_NANE = "lmn";
private static final String XYZ_NANE = "xyz";
private static final String ABC_UPDATED_NANE = "abc - updated";
private static final String LMN_UPDATED_NANE = "lmn - updated";
private static final String XYZ_UPDATED_NANE = "xyz - updated";
private ListGridRecord[] cacheData = new ListGridRecord[3];
private DataSource dataSource;
private SelectItem selectList;
@Override
public void onModuleLoad() {
int i = 0;
cacheData[i] = new ListGridRecord();
cacheData[i].setAttribute(ID, ABC_ID);
cacheData[i].setAttribute(NAME, ABC_NANE);
cacheData[i].setAttribute(VISIBILITY, "Me");
i++;
cacheData[i] = new ListGridRecord();
cacheData[i].setAttribute(ID, LMN_ID);
cacheData[i].setAttribute(NAME, LMN_NANE);
cacheData[i].setAttribute(VISIBILITY, "Group");
i++;
cacheData[i] = new ListGridRecord();
cacheData[i].setAttribute(ID, XYZ_ID);
cacheData[i].setAttribute(NAME, XYZ_NANE);
cacheData[i].setAttribute(VISIBILITY, "Everyone");
final VLayout appLayout = new VLayout();
appLayout.setWidth100();
appLayout.setHeight100();
createDataSource();
createSelectList();
loadData();
CheckboxItem updateAbc = new CheckboxItem("update_abc");
updateAbc.addChangedHandler(event -> {
ListGridRecord r = new ListGridRecord();
r.setAttribute(ID, ABC_ID);
r.setAttribute(NAME, ABC_UPDATED_NANE);
r.setAttribute(VISIBILITY, "Me");
dataSource.updateData(r);
});
CheckboxItem updateLmn = new CheckboxItem("update_lmn");
updateLmn.addChangedHandler(event -> {
ListGridRecord r = new ListGridRecord();
r.setAttribute(ID, LMN_ID);
r.setAttribute(NAME, LMN_UPDATED_NANE);
r.setAttribute(VISIBILITY, "Group");
dataSource.updateData(r);
});
CheckboxItem updateXyz = new CheckboxItem("update_xyz");
updateXyz.addChangedHandler(event -> {
ListGridRecord r = new ListGridRecord();
r.setAttribute(ID, XYZ_ID);
r.setAttribute(NAME, XYZ_UPDATED_NANE);
r.setAttribute(VISIBILITY, "Everyone");
dataSource.updateData(r);
});
appLayout.setMargin(5);
appLayout.setMembersMargin(5);
DynamicForm form = new DynamicForm();
form.setItems(selectList, updateAbc, updateLmn, updateXyz);
appLayout.addMembers(form);
appLayout.draw();
}
private void createDataSource() {
dataSource = new DataSource();
DataSourceField filterIdField = new DataSourceField(ID, FieldType.TEXT, "ID");
filterIdField.setPrimaryKey(true);
DataSourceField filterNameField = new DataSourceField(NAME, FieldType.TEXT, "Name");
DataSourceField visibilityField = new DataSourceField(VISIBILITY, FieldType.TEXT, "Visible To");
dataSource.setFields(filterIdField, filterNameField, visibilityField);
dataSource.setClientOnly(true);
}
private void createSelectList() {
selectList = new SelectItem("test");
selectList.setWidth(300);
selectList.setAllowEmptyValue(Boolean.TRUE);
selectList.setEmptyDisplayValue("-- NONE --");
selectList.setEscapeHTML(Boolean.TRUE);
selectList.setOptionDataSource(dataSource);
selectList.setTitle("Test");
selectList.setCachePickListResults(Boolean.FALSE);
ListGridField filterNameField = new ListGridField(NAME);
filterNameField.setShowHover(Boolean.TRUE);
ListGridField visibilityField = new ListGridField(VISIBILITY);
selectList.setPickListFields(filterNameField, visibilityField);
ListGrid pickListProperties = new ListGrid();
pickListProperties.setCanGroupBy(Boolean.FALSE);
selectList.setPickListProperties(pickListProperties);
selectList.setValueField(ID);
selectList.setDisplayField(NAME);
selectList.setSortField(NAME);
selectList.setPrompt("Select Filter to use");
selectList.setShowTitle(Boolean.FALSE);
selectList.setWrapTitle(Boolean.FALSE);
}
public void loadData() {
dataSource.setCacheData(cacheData);
}
}
Steps:
1. Expand the SelectItem.
2. Sort by Name.
3. Select option "xyz".
4. Click the "update_xyz" button. >>> this will update the "xyz" option to "xyz - updated"
5. Expand the SelectItem.
6. Sort by Name.
7. Select option "abc".
8. Click the "update_abc" button. >>> this will update the abc option to "abc - updated"
9. Expand the SelectItem.
There are duplicate "--NONE--"options and the "xyz - updated" option is removed from the list.
Comment