If I call RPCManager.exportContent passing in a ListGrid, 2 rpc calls are made to the server for operation getPdfObject and as a result I get 2 requests to save the pdf output. However, if I pass in a Layout that contains the ListGrid, then only a single request to the server is made for operation getPdfObject.
Below is sample code to reproduce it.
"Download PDF - 1" passes in the layout and results in 1 request as expected.
"Download PDF - 2" passes in the listgrid and results in 2 requests.
Using: SmartClient Version: v9.1p_2014-09-20/Pro Deployment (built 2014-09-20)
Below is sample code to reproduce it.
"Download PDF - 1" passes in the layout and results in 1 request as expected.
"Download PDF - 2" passes in the listgrid and results in 2 requests.
Code:
public class Sandbox1 implements EntryPoint { DataSource dataSource; ListGrid grid; int counter = 0; ListGridRecord[] cacheData = new ListGridRecord[3]; @Override public void onModuleLoad() { cacheData[0] = new ListGridRecord(); cacheData[0].setAttribute("fldId", 1); cacheData[0].setAttribute("fld1", "val 1"); cacheData[0].setAttribute("fld2", 10); cacheData[0].setAttribute("fld3", new Date()); cacheData[1] = new ListGridRecord(); cacheData[1].setAttribute("fldId", 2); cacheData[1].setAttribute("fld1", "val 2"); cacheData[1].setAttribute("fld2", 20); cacheData[1].setAttribute("fld3", new Date()); cacheData[2] = new ListGridRecord(); cacheData[2].setAttribute("fldId", 3); cacheData[2].setAttribute("fld1", "val 3"); cacheData[2].setAttribute("fld2", 30); cacheData[2].setAttribute("fld3", new Date()); final VLayout appLayout = new VLayout(); appLayout.setWidth100(); appLayout.setHeight100(); buildDataSource(); buildGrid(); IButton downloadPdf1 = new IButton("Download PDF - 1"); downloadPdf1.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { DSRequest reqProps = new DSRequest(); reqProps.setAttribute("skinName", "Enterprise"); reqProps.setAttribute("pdfName", "export"); RPCManager.exportContent(appLayout, reqProps); } }); IButton downloadPdf2 = new IButton("Download PDF - 2"); downloadPdf2.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { DSRequest reqProps = new DSRequest(); reqProps.setAttribute("skinName", "Enterprise"); reqProps.setAttribute("pdfName", "export"); RPCManager.exportContent(grid, reqProps); } }); appLayout.setMargin(5); appLayout.setMembersMargin(5); appLayout.addMembers(downloadPdf1, downloadPdf2, grid); appLayout.draw(); } private void buildGrid() { grid = new ListGrid(); grid.setWidth100(); grid.setHeight100(); grid.setDataFetchMode(FetchMode.PAGED); grid.setDataPageSize(100); // Experimenting with some tweaks to draw ahead ratios. grid.setDrawAheadRatio(1.5F); grid.setQuickDrawAheadRatio(3.0F); grid.setTitle("Test Grid"); grid.setAutoFitFieldsFillViewport(Boolean.TRUE); grid.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH); grid.setAutoFitFieldWidths(Boolean.TRUE); grid.setCanFreezeFields(Boolean.FALSE); grid.setCanGroupBy(Boolean.FALSE); grid.setRecordComponentPoolingMode(RecordComponentPoolingMode.RECYCLE); grid.setAlternateRecordStyles(Boolean.TRUE); grid.setWidth100(); grid.setAutoFetchData(true); // Disable roll over on grid, consider exposing properties for these later. grid.setShowRollOver(Boolean.FALSE); grid.setUseAdvancedFieldPicker(Boolean.TRUE); // Always use advanced field picker grid.setAdvancedFieldPickerThreshold(0); grid.setSelectionType(SelectionStyle.MULTIPLE); grid.setSelectionAppearance(SelectionAppearance.ROW_STYLE); grid.addRecordClickHandler(new RecordClickHandler() { @Override public void onRecordClick(RecordClickEvent event) { ListGridRecord[] selectedRecords = grid.getSelectedRecords(); if (selectedRecords != null && selectedRecords.length == 1) { GWT.log("1 row selected"); } else { GWT.log(selectedRecords.length + " rows selected"); } } }); grid.addHoverHandler(new HoverHandler() { @Override public void onHover(HoverEvent event) { event.cancel(); } }); grid.addDrawHandler(new DrawHandler() { @Override public void onDraw(DrawEvent event) { GWT.log("Draw event "); } }); grid.addFetchDataHandler(new FetchDataHandler() { @Override public void onFilterData(FetchDataEvent event) { GWT.log("FetchDataEvent event "); } }); grid.addRowContextClickHandler(new RowContextClickHandler() { @Override public void onRowContextClick(RowContextClickEvent event) { GWT.log("RowContextClickEvent event "); } }); grid.addDataArrivedHandler(new DataArrivedHandler() { @Override public void onDataArrived(DataArrivedEvent event) { GWT.log("DataArrivedEvent event "); } }); grid.addFieldStateChangedHandler(new FieldStateChangedHandler() { @Override public void onFieldStateChanged(final FieldStateChangedEvent event) { GWT.log("FieldStateChangedEvent event "); } }); ListGridField gfld1 = new ListGridField("fld1", "Field 1"); ListGridField gfld2 = new ListGridField("fld2", "Field 2"); ListGridField gfld3 = new ListGridField("fld3", "Field 3"); grid.setFields(gfld1, gfld2, gfld3); grid.setDataSource(dataSource, grid.getAllFields()); } private void buildDataSource() { dataSource = new DataSource(); dataSource.setClientOnly(true); dataSource.setDataFormat(DSDataFormat.JSON); DataSourceField fldId = new DataSourceField("fldId", FieldType.INTEGER); fldId.setPrimaryKey(true); DataSourceField fld1 = new DataSourceField("fld1", FieldType.TEXT); DataSourceField fld2 = new DataSourceField("fld2", FieldType.INTEGER); DataSourceField fld3 = new DataSourceField("fld3", FieldType.DATE); dataSource.setFields(fldId, fld1, fld2, fld3); dataSource.setCacheData(cacheData); } }
Comment