Hi,
we have a problem with the function JSOHelper.convertToMap (ListGridRecord.getJsObj()) if the record is >expanded<.
Click the "Test" button once with and once without expanded ListGrid
Testcase (BuiltInDS):
We need all the fields of the record as a map.
used: smartgwtpower 2.5, Build 2011/01/28
Regards,
Timo
we have a problem with the function JSOHelper.convertToMap (ListGridRecord.getJsObj()) if the record is >expanded<.
Code:
Exception occurred: (RangeError): Maximum call stack size exceeded. line: 3 sourceId: 4743236136 sourceURL:
Testcase (BuiltInDS):
Code:
package com.smartgwt.sample.client;
import java.util.Map;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.GWT.UncaughtExceptionHandler;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.ExpansionMode;
import com.smartgwt.client.util.JSOHelper;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.ValuesManager;
import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.VLayout;
import com.smartgwt.client.widgets.layout.VStack;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class BuiltInDS implements EntryPoint {
private ListGrid boundList;
/**
* This is the entry point method.
*/
@Override
public void onModuleLoad() {
GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
@Override
public void onUncaughtException(Throwable e) {
GWT.log("Exception occurred: ", e);
SC.warn("Exception occurred: " + e.getMessage());
}
});
VStack vStack = new VStack();
vStack.setLeft(175);
vStack.setTop(75);
vStack.setWidth("70%");
vStack.setMembersMargin(20);
boundList = new ListGrid()
{
@Override
protected Canvas getExpansionComponent(final ListGridRecord record) {
final ValuesManager vm = new ValuesManager();
vm.setDataSource(DataSource.get("animals"));
vm.editRecord(record);
final ListGrid grid = this;
VLayout layout = new VLayout(5);
layout.setPadding(5);
final DynamicForm df = new DynamicForm();
df.setNumCols(4);
df.setUseAllDataSourceFields(false);
df.setDataSource(DataSource.get("animals"));
df.setValuesManager(vm);
TextItem animal = new TextItem ("commonName");
TextItem scientificName = new TextItem ("scientificName");
df.setFields(animal, scientificName);
TextItem lifeSpan = new TextItem ("lifeSpan");
ComboBoxItem status = new ComboBoxItem ("status");
final DynamicForm df2 = new DynamicForm();
df2.setNumCols(4);
df2.setUseAllDataSourceFields(false);
df2.setDataSource(DataSource.get("animals"));
df2.setValuesManager(vm);
df2.setFields(lifeSpan, status);
IButton saveButton = new IButton("Save");
saveButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
vm.saveData();
grid.collapseRecord(record);
}
});
IButton cancelButton = new IButton("Done");
cancelButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
grid.collapseRecord(record);
}
});
HLayout hLayout = new HLayout(10);
hLayout.setAlign(Alignment.CENTER);
hLayout.addMember(saveButton);
hLayout.addMember(cancelButton);
layout.addMember(df);
layout.addMember(df2);
layout.addMember(hLayout);
return layout;
}
};
boundList.setDataSource(DataSource.get("animals"));
boundList.setCanExpandRecords(true);
boundList.setExpansionMode(ExpansionMode.EDITOR);
boundList.setHeight(200);
boundList.setCanEdit(true);
boundList.setExpansionCanEdit(true);
boundList.fetchData();
boundList.setAutoSaveEdits(true);
boundList.addRecordClickHandler(new RecordClickHandler() {
@Override
public void onRecordClick(RecordClickEvent event) {
Record record = event.getRecord();
}
});
vStack.addMember(boundList);
IButton testButton = new IButton("Test");
testButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
ListGridRecord record = boundList.getSelectedRecord();
if (record==null) {
SC.say("nothing");
return;
}
// We need a map but JSOHelper.convertToMap produces error if ExpansionComponent is activated
Map<String, Object> map = JSOHelper.convertToMap(record.getJsObj());
SC.say(map.get("commonName").toString());
}
});
vStack.addMember(testButton);
HLayout hLayout = new HLayout(10);
hLayout.setMembersMargin(10);
hLayout.setHeight(22);
vStack.addMember(hLayout);
vStack.draw();
}
}
used: smartgwtpower 2.5, Build 2011/01/28
Regards,
Timo
Comment