I need to customize a fiori elements app (F1595 - stock multiple materials). It is required to print the result after filtering (with filters applied).
- Is there an existing way of print fiori elements data? (I haven't found one, which I don't understand why you won't be able to print your analyses per default)
- If not, how to extend this app with business application studio to add a print button?
It would even be ok to just print the page as pdf/image if there is no other option to print the data but I wan't to check the possibilities first.
UPDATE:
I've created a jQuery script to load the html of the analytics table data to a new table and print it, which works for tables, that fit screen size. Larger tables seems to dynamically load new rows while scrolling but removing all the rows, that are out of screen. I'll share my script here:
const table = [];
const tabledetails = {};
const getAnalyticalTable = () => {
$.each($('table'), function(){
let id = $(this).attr('id');
let prefix = id.split("--")[0];
let tabledesc = id.split("--")[1];
if(id.indexOf("analyticalTable") !== -1)
{
table.includes(prefix) ? "" : table.push(prefix);
table.includes(tabledesc) ? "" : table.push(tabledesc);
}
});
for (let i = 0; i < table.length; i++)
{
if(table[i].indexOf("header") !== -1)
{
tabledetails['header'] = $(document.getElementById(table[0]+"--"+table[i]));
}
if(table[i].indexOf("-table") !== -1 && table[i].indexOf("-fixrow-bottom") === -1)
{
tabledetails['body'] = $(document.getElementById(table[0]+"--"+table[i]));
}
if(table[i].indexOf("fixrow-bottom") !== -1)
{
tabledetails['footer'] = $(document.getElementById(table[0]+"--"+table[i]));
}
}
return tabledetails;
}
const buildPrintableTable = (tabledetails) => {
let table = '<table><thead><tr>';
$.each(tabledetails['header'].find('td'), function(){
table += '<th>'+$(this).text()+"</th>";
});
table += "</tr></thead>";
$.each(tabledetails['body'].find('tr'), function(){
table += '<tr>';
$.each($(this).find('td'), function() {
table += '<td>'+$(this).text()+"</td>";
});
table += '</tr>';
});
table += "<tbody>";
return table;
}
const printTable = (html) => {
var win = window.open("about:blank", "Print View");
win.document.write(
'<html>\
<body>\
</body>\
</html>');
win.document.writeln(html);
setTimeout(function() {
win.document.close();
win.focus();
// win.print();
// win.close();
}, 300);
}
let tableData = getAnalyticalTable();
let htmlTable = buildPrintableTable(tableData);
printTable(htmlTable);
Anyone knows, how to load the whole table on client side only? - This would be an appropriate workaround to print the data.