Code:
loadAllRecords(max, { exportClientData() });
loadAllRecords(max, { exportClientData() });
if ( // If grouped (workLG.isGrouped() && workLG.getOriginalResultSet() != null && workLG.getOriginalResultSet().lengthIsKnown()) // If ungrouped || (!workLG.isGrouped() && workLG.getResultSet() != null && workLG.getResultSet().lengthIsKnown())) { ResultSet workRS = workLG.isGrouped() ? workLG.getOriginalResultSet() : workLG.getResultSet(); if (workRS.getLength() > 0) { // Otherwise the export will not send a request and the SC.clearPrompt() call below will not be executed, effectively blocking the // application SC.showPrompt(I18nEdited.notification(), I18nEdited.exportStarted()); } // Not all data is loaded clientside, so we load it with workRS.getRange(). In order to trigger the export directly after this // (the method does not have a CallBack, which would make this more easy), DataArrivedHandler is used. This handler is removed // again later in the CallBack of the exportListGrid.exportClientData() call. if (!workRS.allMatchingRowsCached()) { SC.logInfo( StringFormatter.format("Adding DataArrivedHandler to ResultSet {0} of ListGrid {1}", workRS.getID(), workLG.getID())); // Will be removed afterwards again loadAdditionalDataHandler = workRS.addDataArrivedHandler(new DataArrivedHandler() { @Override public void onDataArrived(DataArrivedEvent event) { exportClientData(workLG); } }); workRS.getRange(0, workRS.getLength()); } else { exportClientData(workLG); } } private void exportClientData(ListGrid exportListGrid) { DSRequest exportRequest = getExportRequest(exportListGrid); SC.logInfo(StringFormatter.format("Starting exportClientData of ListGrid {0}", exportListGrid.getID())); exportListGrid.exportClientData(exportRequest, new RPCCallback() { @Override public void execute(RPCResponse response, Object rawData, RPCRequest request) { SC.clearPrompt(); if (loadAdditionalDataHandler != null) { SC.logInfo(StringFormatter.format("Removing DataArrivedHandler of ListGrid {0} added previously", exportListGrid.getID())); loadAdditionalDataHandler.removeHandler(); loadAdditionalDataHandler = null; } SC.logInfo(StringFormatter.format("exportClientData of ListGrid {0} finished", exportListGrid.getID())); } }); }
Leave a comment: