Customizing Downloaded Filenames?
Customizing Downloaded Filenames?

I'd like to be able to customize the title of downloaded PDFs by using the data from a table row and column name.
For example in my DT definition below, where I have title: 'MyCompanyName ProjectName'
I'd like to instead do something like title: 'MyCompanyName {d.deviceName[0]}'
. Which would yield a title something like MyCompanyName Project Xyz
Is this possible?
<sa-datatable
[options]="{
data: nodeDataList,
columns: [
{data: 'deviceName'},
{data: 'dataValue'},
{data: 'dataUnits'},
{data: 'dataType'},
{data: 'dateRecorded'},
{data: 'latitude'},
{data: 'longitude'},
{data: 'location'},
{data: 'clientWanIp'},
{data: 'deviceStatus'},
{data: 'tangleAddress'},
{data: 'transTag'}
],
buttons: [
'copy', 'csv',
{
extend: 'excelHtml5',
title: 'MyCompanyName ProjectName',
autoFilter: true,
sheetName: 'Device Node Data'
},
{
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'LEGAL',
title: 'MyCompanyName Device Node Data',
exportOptions: {
columns: [0, 1, 2, 3, 4, 5, 8, 7, 8, 9],
orthogonal: 'export'
}
}
],
select: {
style: 'multiple',
selector: 'td:first-child'
},
fixedColumns: false,
order: [[ 4, 'asc']],
searching: true,
search: {
smart: false
}
}"
tableClass="table table-striped table-bordered table-hover">
<thead>
<tr>
<th data-hide="mobile-p">Device Name</th>
<th data-hide="mobile-p">Data Value</th>
<th data-hide="mobile-p">Data Units</th>
<th data-hide="mobile-p">Data Type</th>
<th data-hide="mobile-p">Date Recorded</th>
<th data-hide="mobile-p">Latitude</th>
<th data-hide="mobile-p">Longitude</th>
<th data-hide="mobile-p">Location</th>
<th data-hide="mobile-p">Client WAN IP</th>
<th data-hide="mobile-p">Device Status</th>
<th data-hide="mobile-p">Tangle Address</th>
<th data-hide="mobile-p">Tangle Tag</th>
</tr>
</thead>
</sa-datatable>
Thanks!
This discussion has been closed.
Answers
You can do that by making
title
a function, see here - it's adding the search string to the title.Colin