Browser: Firefox 52.0
Smartgwt : Version 6.1p, Built 2017-09-05
GWT: 2.7
I am trying to select a listgrid record that has been grouped. I use the listgrid.getGroupTree().findIndex() to locate the record. This works as long as I only group max of 50 records. If my server returns 51 then the select no longer works. Below is the code snippet. I have tried doing different approaches. One was to use the dataArrivedCallback() which made no difference. One was to capture when the GoupBy was finished and then try the select. Nothing seemed to work.
MyProject.java
public class MyProject implements EntryPoint {
ListGrid grid = null;
public void onModuleLoad() {
VLayout mainContainer = new VLayout();
mainContainer.setWidth(800);
mainContainer.setHeight(500);
mainContainer.addMember(buildListGrid());
RootPanel.get("mainContainer").add(mainContainer);
fetchData();
}
private ListGrid biuldListGrid() {
grid = new ListGrid();
ListGridField name = new ListGridField("name", "Name");
ListGridField id = new ListGridField("id", "ID", 100);
grid.setFields(id, name);
MyDS ds = new MyDS("id");
grid.setDataSource(ds);
grid.setGroupStartOpen(GroupStartOpen.ALL);
grid.groupBy("name");
grid.setHeight(400);
}
protectred void fetchData() {
grid.fetchData(new Criteria(), new DSCallback() {
@Override
public void execute(DSResponse response, Object rawData, DSRequest request) {
selectEntry();
}
}
}
protected void selectEntry() {
int index = grid.getGroupTree().findIndex("id", "10");
grid.selectRange(index, index+1);
}
}
public class MyDS extends RestDataSource {
public MyDS() {
this("myds");
}
public MyDS(String id) {
setID(id);
setClientOnly(false);
setDataFormat(DSDataFormat.JSON);
setJsonPrefix("");
setJsonSuffix("");
OperationBinding fetch = new OperationBinding();
fetch.setOperationType(DSOperationType.FETCH);
DSRequest fetchProps = new DSRequest();
fetchProps.setHttpMethod("GET");
fetch.setRequestProperties(fetchProps);
setOperationBindings(fetch);
init();
}
protected void init() {
DataSourceField id = new DataSourceField("id", "ID");
id.setPrimaryKey(true);
id.setHidden(true);
DataSourceField name = new DataSourceTextField("name", "Name");
setFields(id, name);
}
}
I create the data as follows on my Server:
public List<MyData> createDummyData() {
List<MyData> data = new ArrayList<MyData>();
int cnt = 51;
int skip = 0;
String name = "name"+0;
for (int i=0; i<cnt; i++) {
MyData d = new MyData();
if (skip > 2) {
name = "name" + i;
skip = 0;
}
skip++;
d.setId(i+"");
d.setName(name);
data.add(d);
}
return data;
}
public class MyData {
private String id;
private String name;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Smartgwt : Version 6.1p, Built 2017-09-05
GWT: 2.7
I am trying to select a listgrid record that has been grouped. I use the listgrid.getGroupTree().findIndex() to locate the record. This works as long as I only group max of 50 records. If my server returns 51 then the select no longer works. Below is the code snippet. I have tried doing different approaches. One was to use the dataArrivedCallback() which made no difference. One was to capture when the GoupBy was finished and then try the select. Nothing seemed to work.
MyProject.java
public class MyProject implements EntryPoint {
ListGrid grid = null;
public void onModuleLoad() {
VLayout mainContainer = new VLayout();
mainContainer.setWidth(800);
mainContainer.setHeight(500);
mainContainer.addMember(buildListGrid());
RootPanel.get("mainContainer").add(mainContainer);
fetchData();
}
private ListGrid biuldListGrid() {
grid = new ListGrid();
ListGridField name = new ListGridField("name", "Name");
ListGridField id = new ListGridField("id", "ID", 100);
grid.setFields(id, name);
MyDS ds = new MyDS("id");
grid.setDataSource(ds);
grid.setGroupStartOpen(GroupStartOpen.ALL);
grid.groupBy("name");
grid.setHeight(400);
}
protectred void fetchData() {
grid.fetchData(new Criteria(), new DSCallback() {
@Override
public void execute(DSResponse response, Object rawData, DSRequest request) {
selectEntry();
}
}
}
protected void selectEntry() {
int index = grid.getGroupTree().findIndex("id", "10");
grid.selectRange(index, index+1);
}
}
public class MyDS extends RestDataSource {
public MyDS() {
this("myds");
}
public MyDS(String id) {
setID(id);
setClientOnly(false);
setDataFormat(DSDataFormat.JSON);
setJsonPrefix("");
setJsonSuffix("");
OperationBinding fetch = new OperationBinding();
fetch.setOperationType(DSOperationType.FETCH);
DSRequest fetchProps = new DSRequest();
fetchProps.setHttpMethod("GET");
fetch.setRequestProperties(fetchProps);
setOperationBindings(fetch);
init();
}
protected void init() {
DataSourceField id = new DataSourceField("id", "ID");
id.setPrimaryKey(true);
id.setHidden(true);
DataSourceField name = new DataSourceTextField("name", "Name");
setFields(id, name);
}
}
I create the data as follows on my Server:
public List<MyData> createDummyData() {
List<MyData> data = new ArrayList<MyData>();
int cnt = 51;
int skip = 0;
String name = "name"+0;
for (int i=0; i<cnt; i++) {
MyData d = new MyData();
if (skip > 2) {
name = "name" + i;
skip = 0;
}
skip++;
d.setId(i+"");
d.setName(name);
data.add(d);
}
return data;
}
public class MyData {
private String id;
private String name;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Comment