Is there a way to access column data within a messageTop
Is there a way to access column data within a messageTop
Hi All, Basically I am currently printing a message displaying a count of occurrence's within a column, but i want to add to the string the cell data specific to the count. Inside my if else statement i want to chain on the value matched in column [0]. I have been able to find an answer to this so unsure if its even possible.
Currently my message reads 'There are 3 requests between x and y' f
However I want it to state
'There are 3 requests between x and y for "Patients"'
messageTop: function () {
var minCount = $('#min-date-count').val();
var maxCount = $('#max-date-count').val();
if (minCount !== '' && maxCount !== '') {
return 'There are ' + countTable.rows({ search: 'applied' }).count() + ' requests between ' + minCount + ' & ' + maxCount
}
else if (minCount !== '' && maxCount !== '' && data[0] == 'Patient') {
return 'There are ' + countTable.rows({ search: 'applied' }).count() + ' requests from Patients'
}
else return 'Number of requests: ' + countTable.rows({ search: 'applied' }).count()
},
Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide
Answers
Are you saying you want to add the search term used? If so you can use
search()
if its the global search term you are looking for.If this doesn't help please provide a link to your page or a test case showing the issue with specifics of the text you want to add.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Hey thank you for getting back to me I will try figure out the test case, in the mean time my printed PDF looks like the below, So in this instance instead of exporting the column data, is it possible to append Coal Miners through conditional logic to the end of the number of requests. Baring in mind the column holds 6 different values
Report: Number of Requests Received
Number of requests: 3
Requestor
Coal Miners
Coal Miners
Coal Miners
Fri Feb 26 2021 21:31
I'm not sure exactly what you want to do. If you want to customize the table output then you will likely need to use customize option. Take a look at the code snippet in this thread for an idea of what this might look like.
Kevin