Hi,
I am using SmartGWTPro 3.0 and Google Chrome version 16.0.
I tried to export the grid contents to CSV file. But I am unable to do so.
I found that, on clicking export button, the application sends a POST request to the server.
The code for export data is
DataSource is
What could be the issue ?
Mainly I need to export the data which is available in the list grid (client data).
Any suggestion please ?!!
I am using SmartGWTPro 3.0 and Google Chrome version 16.0.
I tried to export the grid contents to CSV file. But I am unable to do so.
I found that, on clicking export button, the application sends a POST request to the server.
The code for export data is
Code:
DeviceListDS dataSource = new DeviceListDS();
final ListGrid deviceGrid = new ListGrid();
deviceGrid.setShowFilterEditor(true);
deviceGrid.setFilterOnKeypress(true);
deviceGrid.setDataSource(dataSource);
deviceGrid.setWidth100();
deviceGrid.setHeight(200);
deviceGrid.setAutoFetchData(true);
IButton exportButton = new IButton();
exportButton.setTitle("Export");
exportButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
DSRequest dsRequestProperties = new DSRequest();
dsRequestProperties.setExportAs(ExportFormat.CSV);
dsRequestProperties.setExportDisplay(ExportDisplay.DOWNLOAD);
deviceGrid.exportData(dsRequestProperties);
}
});
devLayout.addMember(deviceGrid);
devLayout.addMember(exportButton);
Code:
package comd.example.myproject.client.DataSource;
import com.smartgwt.client.data.XJSONDataSource;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.DSDataFormat;
public class DeviceListDS extends XJSONDataSource {
public DeviceListDS() {
setDataFormat(DSDataFormat.JSON);
setRecordXPath("deviceList");
setDataURL("http://localhost:8080/agentManager/device/device/?groupId=0");
DataSourceTextField deviceModel = new DataSourceTextField(
"deviceModel", "Device Model");
DataSourceTextField sysName = new DataSourceTextField("sysName",
"Device Name");
DataSourceTextField ipAddress = new DataSourceTextField("ipAddress",
"IP Address");
DataSourceTextField sysLocation = new DataSourceTextField(
"sysLocation", "System Location");
DataSourceTextField description = new DataSourceTextField(
"description", "Description");
DataSourceTextField subnetMask = new DataSourceTextField("subnetMask",
"SubnetMask");
DataSourceTextField statusId = new DataSourceTextField("statusId",
"Status Id");
setFields(deviceModel, sysName, ipAddress, sysLocation, description,
subnetMask, statusId);
}
}
Mainly I need to export the data which is available in the list grid (client data).
Any suggestion please ?!!
Comment