Hey guys, I've been troubled with this problem over 10 days already.
I think I tried everything I could think of and still no solution for it.
I have a ListGrid and one of the cell should hold a ListBox(ComboBoxItem or SelectItem in SmartGWT).
private void makeListGridField() {
DataSource dataSource = new CompanyDataSource("companyList");
dataSource.setClientOnly(true);
// listGrid.setAlwaysShowEditors(true);
listGrid.setHeight(400);
listGrid.setWidth(850);
listGrid.setShowAllRecords(true);
listGrid.setDataSource(dataSource);
// listGrid.setHeaderTitleStyle("gwt-ListGrid-header");
ListGridField date = new ListGridField("date", "Date", 132);
date = setFieldAlignCenter(date);
ListGridField alias = new ListGridField("alias", "Alias", 113);
alias = setFieldAlign(alias);
ListGridField xletName = new ListGridField("xletName", "Xlet Name", 267);
xletName = setFieldAlign(xletName);
ListGridField timeStamp = new ListGridField("timeStamp", "TimeStamp",
97);
timeStamp = setFieldAlignCenter(timeStamp);
ListGridField iteration = new ListGridField("iteration", "Iteration",
57);
iteration = setFieldAlign(iteration);
ListGridField status = new ListGridField("status", "Status", 77);
status = setFieldAlign(status);
status.setCanEdit(true);
ListGridField actions = new ListGridField("actions", "Actions", 102);
actions.setValueMap("Choose Actions", "Delete", "View Result");
// SelectItem actions = new SelectItem("actions", "Actions");
// actions = setFieldAlignCenter(actions);
// actions.setValueMap("Choose Actions", "Delete", "View Result");
// actions.addChangedHandler(new ChangedHandler() {
//
// @Override
// public void onChanged(ChangedEvent event) {
// Window.alert("fuck");
//
// }
// });
listGrid.setAutoFetchData(true);
listGrid.setEditEvent(ListGridEditEvent.CLICK);
listGrid.setFields(date, alias, xletName, timeStamp, iteration, status, actions);
webListGrid.add(listGrid);
}
private void updateRows(String result) {
JSONArray jArr = (JSONArray) JSONParser.parse(result);
JSONObject jOjb = null;
int len = jArr.size();
Record[] recordArr = new Record[len];
for (int i = 0; i < len; i++) {// for
jOjb = (JSONObject) jArr.get(i);
if( jOjb != null ){
String date = format.format(new Date(Long.parseLong(jOjb.get(
"timeStamp").toString().replaceAll("\"", ""))));
String alias = jOjb.get("alias").toString().replaceAll("\"", "");
String xletName = jOjb.get("xletName").toString().replaceAll("\"",
"");
String timeStamp = jOjb.get("timeStamp").toString().replaceAll(
"\"", "");
String ite = jOjb.get("iteration").toString().replaceAll("\"", "");
if (ite.equals("null")) {
ite = "100";
}
String iteration = Integer.parseInt(ite) <= 100 ? "Light"
: (Integer.parseInt(ite) <= 200 ? "Medium" : "Heavy");
String status = jOjb.get("status").toString().replaceAll("\"", "");
ComboBoxItem cbi = new ComboBoxItem("actions", "actions");
cbi.setValueMap("Choose Action", "Delete", "View Result");
ListGridRecord record = new ListGridRecord();
record.setAttribute("alias", alias);
record.setAttribute("xletName", xletName);
record.setAttribute("date", date);
record.setAttribute("timeStamp", timeStamp);
record.setAttribute("iteration", iteration);
record.setAttribute("status", status);
record.setAttribute("actions", "Choose Action");
recordArr[i] = record;
// Actions listBox = new Actions(status, i);
// listBox.init();
// listGrid.addData(new CompanyRecord(date, alias, xletName,
// timeStamp, iteration, status, cbi));// ,
}
}// for
listGrid.setUseAllDataSourceFields(true);
listGrid.setData(recordArr);
// listGrid.focus();
// listGrid.focusInFilterEditor();
// listGrid.setEditOnFocus(true);
// listGrid.setData(comArr);
}// updateRows
public class CompanyDataSource extends DataSource {
public CompanyDataSource(String id) {
setID(id);
// DataSourceDateField date = new DataSourceDateField("date", "Date");
// date.setPrimaryKey(true);
DataSourceTextField date = new DataSourceTextField("date", "Date");
date.setPrimaryKey(true);
date.setRequired(true);
DataSourceTextField alias = new DataSourceTextField("alias", "Alias");
DataSourceTextField xletName = new DataSourceTextField("xletName",
"Xlet Name");
DataSourceTextField timeStamp = new DataSourceTextField("timeStamp",
"TimeStamp");
DataSourceTextField iteration = new DataSourceTextField("iteration",
"Iteration");
DataSourceTextField status = new DataSourceTextField("status", "Status");
// DataSourceTextField actions = new DataSourceTextField("actions","Actions");
DataSourceEnumField actions = new DataSourceEnumField("actions", "Actions", 10);
// actions.setType(FieldType.ENUM);
// DataSourceField actions = new DataSourceField("actions", FieldType.ENUM);
// DataSourceEnumField actions = new DataSourceEnumField("actions", "Actions");
// DataSourceTextField actions = new DataSourceTextField("valueMap",
// "Actions");
// actions.setAttribute("actions", new String[]{"Choose Action", "Delete", "View Result"});
actions.setValueMap("Choose Action", "Delete", "View Result");
actions.setCanEdit(true);
setFields(date, alias, xletName, timeStamp, iteration, status, actions);
setClientOnly(true);
}
}
I can't not show you guys all the source code. sorry for that.
Anyway, I have a method which sets the ListGridFields called makeListGridField().
and updateRows() is the method where actually setting the values.
Any Ideas? or suggestions?? would be really appreciated~~
Thanks in advance
I think I tried everything I could think of and still no solution for it.
I have a ListGrid and one of the cell should hold a ListBox(ComboBoxItem or SelectItem in SmartGWT).
private void makeListGridField() {
DataSource dataSource = new CompanyDataSource("companyList");
dataSource.setClientOnly(true);
// listGrid.setAlwaysShowEditors(true);
listGrid.setHeight(400);
listGrid.setWidth(850);
listGrid.setShowAllRecords(true);
listGrid.setDataSource(dataSource);
// listGrid.setHeaderTitleStyle("gwt-ListGrid-header");
ListGridField date = new ListGridField("date", "Date", 132);
date = setFieldAlignCenter(date);
ListGridField alias = new ListGridField("alias", "Alias", 113);
alias = setFieldAlign(alias);
ListGridField xletName = new ListGridField("xletName", "Xlet Name", 267);
xletName = setFieldAlign(xletName);
ListGridField timeStamp = new ListGridField("timeStamp", "TimeStamp",
97);
timeStamp = setFieldAlignCenter(timeStamp);
ListGridField iteration = new ListGridField("iteration", "Iteration",
57);
iteration = setFieldAlign(iteration);
ListGridField status = new ListGridField("status", "Status", 77);
status = setFieldAlign(status);
status.setCanEdit(true);
ListGridField actions = new ListGridField("actions", "Actions", 102);
actions.setValueMap("Choose Actions", "Delete", "View Result");
// SelectItem actions = new SelectItem("actions", "Actions");
// actions = setFieldAlignCenter(actions);
// actions.setValueMap("Choose Actions", "Delete", "View Result");
// actions.addChangedHandler(new ChangedHandler() {
//
// @Override
// public void onChanged(ChangedEvent event) {
// Window.alert("fuck");
//
// }
// });
listGrid.setAutoFetchData(true);
listGrid.setEditEvent(ListGridEditEvent.CLICK);
listGrid.setFields(date, alias, xletName, timeStamp, iteration, status, actions);
webListGrid.add(listGrid);
}
private void updateRows(String result) {
JSONArray jArr = (JSONArray) JSONParser.parse(result);
JSONObject jOjb = null;
int len = jArr.size();
Record[] recordArr = new Record[len];
for (int i = 0; i < len; i++) {// for
jOjb = (JSONObject) jArr.get(i);
if( jOjb != null ){
String date = format.format(new Date(Long.parseLong(jOjb.get(
"timeStamp").toString().replaceAll("\"", ""))));
String alias = jOjb.get("alias").toString().replaceAll("\"", "");
String xletName = jOjb.get("xletName").toString().replaceAll("\"",
"");
String timeStamp = jOjb.get("timeStamp").toString().replaceAll(
"\"", "");
String ite = jOjb.get("iteration").toString().replaceAll("\"", "");
if (ite.equals("null")) {
ite = "100";
}
String iteration = Integer.parseInt(ite) <= 100 ? "Light"
: (Integer.parseInt(ite) <= 200 ? "Medium" : "Heavy");
String status = jOjb.get("status").toString().replaceAll("\"", "");
ComboBoxItem cbi = new ComboBoxItem("actions", "actions");
cbi.setValueMap("Choose Action", "Delete", "View Result");
ListGridRecord record = new ListGridRecord();
record.setAttribute("alias", alias);
record.setAttribute("xletName", xletName);
record.setAttribute("date", date);
record.setAttribute("timeStamp", timeStamp);
record.setAttribute("iteration", iteration);
record.setAttribute("status", status);
record.setAttribute("actions", "Choose Action");
recordArr[i] = record;
// Actions listBox = new Actions(status, i);
// listBox.init();
// listGrid.addData(new CompanyRecord(date, alias, xletName,
// timeStamp, iteration, status, cbi));// ,
}
}// for
listGrid.setUseAllDataSourceFields(true);
listGrid.setData(recordArr);
// listGrid.focus();
// listGrid.focusInFilterEditor();
// listGrid.setEditOnFocus(true);
// listGrid.setData(comArr);
}// updateRows
public class CompanyDataSource extends DataSource {
public CompanyDataSource(String id) {
setID(id);
// DataSourceDateField date = new DataSourceDateField("date", "Date");
// date.setPrimaryKey(true);
DataSourceTextField date = new DataSourceTextField("date", "Date");
date.setPrimaryKey(true);
date.setRequired(true);
DataSourceTextField alias = new DataSourceTextField("alias", "Alias");
DataSourceTextField xletName = new DataSourceTextField("xletName",
"Xlet Name");
DataSourceTextField timeStamp = new DataSourceTextField("timeStamp",
"TimeStamp");
DataSourceTextField iteration = new DataSourceTextField("iteration",
"Iteration");
DataSourceTextField status = new DataSourceTextField("status", "Status");
// DataSourceTextField actions = new DataSourceTextField("actions","Actions");
DataSourceEnumField actions = new DataSourceEnumField("actions", "Actions", 10);
// actions.setType(FieldType.ENUM);
// DataSourceField actions = new DataSourceField("actions", FieldType.ENUM);
// DataSourceEnumField actions = new DataSourceEnumField("actions", "Actions");
// DataSourceTextField actions = new DataSourceTextField("valueMap",
// "Actions");
// actions.setAttribute("actions", new String[]{"Choose Action", "Delete", "View Result"});
actions.setValueMap("Choose Action", "Delete", "View Result");
actions.setCanEdit(true);
setFields(date, alias, xletName, timeStamp, iteration, status, actions);
setClientOnly(true);
}
}
I can't not show you guys all the source code. sorry for that.
Anyway, I have a method which sets the ListGridFields called makeListGridField().
and updateRows() is the method where actually setting the values.
Any Ideas? or suggestions?? would be really appreciated~~
Thanks in advance
Comment