Hello,
I am having issues with the Excel Export Field names. To test, I created a standalone based on your showcase example: http://www.smartclient.com/smartgwtee/showcase/#excel_export
Here is my entry point (is basically your entry point):
Here my worldDSExport.ds.xml:
It is your datasource WITH THE TITLES DELETED.
When I export to XLS, I get the fieldnames instead of the titles : example: "Country Name" instead of "Country". But the field title is specified in the entry point?!
ListGridField countryName = new ListGridField("countryName", "Country");
So the excel field title should be "Country" instead of "Country Name".
If I leave the field names inside the worldDSExport.ds.xml file, everything works. But I need to specify the titles with java, so I deleted them from the worldDSExport.ds.xml file. I think this is a bug.
The request being sent is:
So here you see that the exportFieldTitles are incorrect ("Country Name" is being sent instead of "Country").
I am using smartgwtee-3.1p nightly 09.02.13 enterprise evaluation (but with recent nightlys I get the same problem).
I am having issues with the Excel Export Field names. To test, I created a standalone based on your showcase example: http://www.smartclient.com/smartgwtee/showcase/#excel_export
Here is my entry point (is basically your entry point):
Code:
public void onModuleLoad() {
DataSource worldDSExport = DataSource.get("worldDSExport");
final ListGrid countryList = new ListGrid();
countryList.setWidth(500);
countryList.setAlternateRecordStyles(true);
countryList.setDataSource(worldDSExport);
countryList.setAutoFetchData(true);
ListGridField countryName = new ListGridField("countryName", "Country");
ListGridField capital = new ListGridField("capital", "Capital");
ListGridField continent = new ListGridField("continent", "Continent");
countryList.setFields(countryName, capital, continent);
countryList.setAutoFitData(Autofit.VERTICAL);
countryList.setShowFilterEditor(true);
countryList.setAutoFitMaxRecords(10);
final DynamicForm exportForm = new DynamicForm();
exportForm.setWidth(300);
SelectItem exportTypeItem = new SelectItem("exportType", "Export Type");
exportTypeItem.setWidth("*");
exportTypeItem.setDefaultToFirstOption(true);
LinkedHashMap valueMap = new LinkedHashMap();
valueMap.put("csv", "CSV (Excel)");
valueMap.put("xml", "XML");
valueMap.put("json", "JSON");
valueMap.put("xls", "XLS (Excel97)");
valueMap.put("ooxml", "XLSX (Excel2007/OOXML)");
exportTypeItem.setValueMap(valueMap);
BooleanItem showInWindowItem = new BooleanItem();
showInWindowItem.setName("showInWindow");
showInWindowItem.setTitle("Show in Window");
showInWindowItem.setAlign(Alignment.LEFT);
exportForm.setItems(exportTypeItem, showInWindowItem);
IButton exportButton = new IButton("Export");
exportButton.addClickHandler(new ClickHandler() {
public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) {
String exportAs = (String) exportForm.getField("exportType").getValue();
FormItem item = exportForm.getField("showInWindow");
boolean showInWindow = item.getValue() == null ? false : (Boolean) item.getValue();
if(exportAs.equals("json")) {
// JSON exports are server-side only, so use the OperationBinding on the DataSource
DSRequest dsRequestProperties = new DSRequest();
dsRequestProperties.setOperationId("customJSONExport");
dsRequestProperties.setExportDisplay(showInWindow ? ExportDisplay.WINDOW : ExportDisplay.DOWNLOAD);
countryList.exportData(dsRequestProperties);
} else {
// exportAs is either XML or CSV, which we can do with requestProperties
DSRequest dsRequestProperties = new DSRequest();
dsRequestProperties.setExportAs((ExportFormat)EnumUtil.getEnum(ExportFormat.values(), exportAs));
dsRequestProperties.setExportDisplay(showInWindow ? ExportDisplay.WINDOW : ExportDisplay.DOWNLOAD);
countryList.exportData(dsRequestProperties);
}
}
});
VLayout layout = new VLayout(15);
layout.setAutoHeight();
HLayout formLayout = new HLayout(15);
formLayout.addMember(exportForm);
formLayout.addMember(exportButton);
layout.addMember(formLayout);
layout.addMember(countryList);
layout.draw();
Code:
<DataSource
ID="worldDSExport"
tableName="worldDS"
serverType="sql"
recordName="country"
testFileName="ds/test_data/world.data.xml"
>
<fields>
<field name="pk" type="sequence" hidden="true" primaryKey="true" />
<field name="countryCode" type="text" required="true" />
<field name="countryName" type="text" required="true" />
<field name="capital" type="text" />
<field name="government" type="text" length="500" />
<field name="continent" type="text" >
<valueMap>
<value>Europe</value>
<value>Asia</value>
<value>North America</value>
<value>Australia/Oceania</value>
<value>South America</value>
<value>Africa</value>
</valueMap>
</field>
<field name="independence" type="date" />
<field name="area" type="float" />
<field name="population" type="integer" />
<field name="gdp" type="float" />
<field name="member_g8" type="boolean" />
</fields>
<operationBindings>
<operationBinding operationType="fetch" operationId="customJSONExport">
<exportResults>true</exportResults>
<exportAs>json</exportAs>
<exportFilename>Results.txt</exportFilename>
<lineBreakStyle>dos</lineBreakStyle>
</operationBinding>
</operationBindings>
</DataSource>
When I export to XLS, I get the fieldnames instead of the titles : example: "Country Name" instead of "Country". But the field title is specified in the entry point?!
ListGridField countryName = new ListGridField("countryName", "Country");
So the excel field title should be "Country" instead of "Country Name".
If I leave the field names inside the worldDSExport.ds.xml file, everything works. But I need to specify the titles with java, so I deleted them from the worldDSExport.ds.xml file. I think this is a bug.
The request being sent is:
Code:
Request #1 (DSRequest) payload: {
criteria:{
},
operationConfig:{
dataSource:"worldDSExport",
operationType:"fetch",
textMatchStyle:"substring"
},
exportResults:true,
exportAs:"xls",
exportDelimiter:",",
exportTitleSeparatorChar:"",
exportFilename:"Export",
exportDisplay:"download",
lineBreakStyle:"default",
exportFields:[
"countryName",
"capital",
"continent"
],
exportFieldTitles:{
countryName:"Country Name",
capital:"Capital",
continent:"Continent"
},
appID:"builtinApplication",
operation:"worldDSExport_fetch",
oldValues:{
}
}
I am using smartgwtee-3.1p nightly 09.02.13 enterprise evaluation (but with recent nightlys I get the same problem).
Comment