Code:
@Override public void onModuleLoad() { final VLayout vlayout = new VLayout(); final ListGrid lg = new ListGrid(); ListGridField nameField = new ListGridField("f_name", "name"); lg.setFields(nameField); lg.setDataSource("simpleTable"); lg.fetchData(); IButton but = new IButton("click me"); but.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { DSRequest properties = new DSRequest(); properties.setExportFilename("Export"); properties.setExportAs(ExportFormat.XLS); properties.setExportDisplay(ExportDisplay.DOWNLOAD); lg.exportData(properties); } }); vlayout.addMember(lg); vlayout.addMember(but); vlayout.setWidth100(); vlayout.setHeight100(); vlayout.draw(); }
For completeness: (although it should be reproducible with any datasource)
Code:
<DataSource ID="simpleTable" serverType="sql" tableName="t_schueler"> <fields> <field name="f_schueler_id" type="sequence" primaryKey="true" /> <field name="f_name" type="text" /> </fields> </DataSource>
Comment