In this scenario I get an error:
"Some records in the range you selected are not loaded. Scroll through the entire range before selecting it."
1. Select first record ("Pat")
2. Click [remove] button
3. Click "Joe" with shift
If I select these two records again, it works.
SmartGWT 13.1d 2024-02-06
macOS 13.2.1
Chrome 121.0.6167.139 , Safari 16.3
Code:
RecordList rl = new RecordList();
rl.add(createTestRecord(1, "Pat", "Smith"));
rl.add(createTestRecord(2, "Sue", "Nowak"));
rl.add(createTestRecord(3, "Joe", "Brown"));
rl.add(createTestRecord(4, "Leo", "White"));
rl.add(createTestRecord(5, "Teo", "McDonald"));
DataSource ds = new DataSource();
ds.setClientOnly(true);
DataSourceIntegerField f1 = new DataSourceIntegerField("id");
f1.setPrimaryKey(true);
DataSourceTextField f2 = new DataSourceTextField("name");
DataSourceTextField f3 = new DataSourceTextField("surname");
ds.setFields(f1, f2, f3);
ds.setCacheData(rl.toArray());
VLayout vl = new VLayout();
ListGrid testGrid = new ListGrid();
testGrid.setDataSource(ds);
testGrid.setAutoFetchData(false);
testGrid.setShowAllRecords(true);
testGrid.fetchData();
Button removeButton = new Button("remove");
removeButton.addClickHandler(new ClickHandler() {
final ListGrid grid = testGrid;
@Override
public void onClick(ClickEvent event) {
Record r = grid.getSelectedRecord();
grid.removeSelectedData(new DSCallback() {
final int recordIndex = grid.getRecordIndex(r);
@Override
public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest) {
grid.selectSingleRecord(recordIndex);
}});
}
});
vl.addMembers(testGrid,removeButton);
Code:
private Record createTestRecord(int id, String name, String surname) {
Record r = new Record();
r.setAttribute("id", id);
r.setAttribute("name", name);
r.setAttribute("surname", surname);
return r;
}