Hello comunity,
I've found a fairly interesting solution for anyone who has the same problem as me.My problem was XLS export took too much time for 60k lines and CSV export didnt add BOM so that the csv file was recognized by EXCEL by double clicking the file.
My solution was to overwrite the ExportData function and fetch the data from the ajax function and redefining the export of the data with de BOM.
Hope you like it 
- Button component expression:
Code:
function exportData(){
render_relatorio.queryState.exportData('csv', null, {filename:'custom_name.csv',separator:';'});
}
- Table Component Post execution :
Code:
function f() {
function hijackQueryComp(comp) {
var oldExportData = comp.exportData;
comp.exportData = function(outputType, overrides, options) {
if (!options) {
options = {};
}
var queryDefinition = this.buildQueryDefinition(overrides);
queryDefinition.outputType = outputType;
if (outputType == 'csv' && options.separator) {
queryDefinition.settingcsvSeparator = options.separator;
}
if (options.filename) {
queryDefinition.settingattachmentName = options.filename;
}
if (outputType == 'xls' && options.template) {
queryDefinition.settingtemplateName = options.template;
}
if (options.columnHeaders) {
queryDefinition.settingcolumnHeaders = options.columnHeaders;
}
delete queryDefinition.pageSize;
delete queryDefinition.pageStart;
if (options.dtFilter != null) {
queryDefinition.settingdtFilter = options.dtFilter;
if (options.dtSearchableColumns != null) {
queryDefinition.settingdtSearchableColumns = options.dtSearchableColumns;
}
}
queryDefinition.wrapItUp = 'false';
$.ajax({
type: 'POST',
dataType: 'text',
async: true,
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
data: queryDefinition,
url: this.getOption('url'),
xhrFields: {
withCredentials: true
},
}).done(function(uuid) {
var data = uuid;
var filename = 'relatorio.csv';
if(!jQuery.isPlainObject(data)) { //is CSV - we use blob
var blob = new Blob(["\ufeff", uuid]);
var URL = window.URL || window.webkitURL;
var downloadUrl = URL.createObjectURL(blob);
}
var a = document.createElement("a");
a.href = jQuery.isPlainObject(data) ? data.file : downloadUrl;
a.download = jQuery.isPlainObject(data) ? data.filename : filename;
document.body.appendChild(a);
a.click();
a.remove();
}).fail(function(jqXHR, textStatus, errorThrown) {
Dashboards.log("Request failed: " + jqXHR.responseText + " :: " + textStatus + " ::: " + errorThrown);
});
}
}
var comp = Dashboards.getComponentByName('render_relatorio');
hijackQueryComp(comp['query']);
hijackQueryComp(comp['queryState']);
}