Browser: Firefox 52.0
Smartgwt : Version 6.1p, Built 2017-09-05
GWT: 2.7
I need to be able to capture when the grouping is finished but it isn't getting invoked. Below are the code snippets.
The json response that is returned is
{"response" : {
"status":0,
"startRow":0,
"endRow":50,
"totalRows":50,
"internalCnt":0,
"data" : [{"name": "name0", "id":"0"}, ....and so on ]
}
}
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);
grid.addGroupByCompleteHandler(new GroupByCompleteHandler() {
@Override
public void onGroupByComplete(GroupByCompleteEvent event) {
SC.say("in group by complete handler");
}
});
}
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 need to be able to capture when the grouping is finished but it isn't getting invoked. Below are the code snippets.
The json response that is returned is
{"response" : {
"status":0,
"startRow":0,
"endRow":50,
"totalRows":50,
"internalCnt":0,
"data" : [{"name": "name0", "id":"0"}, ....and so on ]
}
}
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);
grid.addGroupByCompleteHandler(new GroupByCompleteHandler() {
@Override
public void onGroupByComplete(GroupByCompleteEvent event) {
SC.say("in group by complete handler");
}
});
}
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