tableTools Button Implementation
tableTools Button Implementation
jdadwilson
Posts: 80Questions: 14Answers: 1
I have a simple(?) tableTools button implementation question.
I need to take information from a dataTable that has multiple rows selected and process them individually with a php script. So, it is possible to modify the Print button call to do this or maybe to pass the row information to a 'Print' button handler? Examples of either are most appreciated.
TIA for your assistance
jdadwilson
I need to take information from a dataTable that has multiple rows selected and process them individually with a php script. So, it is possible to modify the Print button call to do this or maybe to pass the row information to a 'Print' button handler? Examples of either are most appreciated.
TIA for your assistance
jdadwilson
This discussion has been closed.
Replies
I now think I made an error doing it that way. I was trying to be too clever and keep the styling etc of the table, but really I should have just copied the data and formatted it specifically for print. That would then make getting the selected rows only trivial, but at the moment you'd need to apply a filter to the table on print and then unfilter on closing the print view.
My plan is to rewrite TableTools at some point in future (although no idea when!) and I'll be changing how the print works...
Allan
, "oTableTools": {
"aButtons": [
{
"sExtends": "ajax"
, "sButtonText": "CSV"
, "fnClick": function () {
var iframe = document.createElement('iframe');
iframe.style.height = "0px";
iframe.style.width = "0px";
var parameters = getParameters($this, settings);
var toolbarParameters = settings.$toolbar.toolbar("getParameters");
var alarmLevels = "";
for (var i = 0; i < parameters.AlarmLevels.length; i++) {
alarmLevels += "&alarmLevel=" + parameters.AlarmLevels[i];
}
var subsystems = "";
for (var i = 0; i < parameters.Subsystems.length; i++) {
subsystems += "&subsystem=" + parameters.Subsystems[i];
}
var alarmMessages = "";
for (var i = 0; i < parameters.AlarmMessages.length; i++) {
alarmMessages += "&alarmMessage=" + encodeURIComponent(parameters.AlarmMessages[i]);
}
iframe.src = "Handler.ashx" +
"?machineId=" + parameters.MachineId +
(alarmLevels == undefined ? "" : alarmLevels) +
"&alarmLevelsEqual=" + parameters.AlarmLevelsEqual +
(subsystems == undefined ? "" : subsystems) +
"&subsystemsEqual=" + parameters.SubsystemsEqual +
(alarmMessages == undefined ? "" : alarmMessages) +
"&alarmMessagesEqual=" + parameters.AlarmMessagesEqual +
"&startDate=" + toolbarParameters.StartDate +
"&startTime=" + toolbarParameters.StartTime +
"&endDate=" + toolbarParameters.EndDate +
"&endTime=" + toolbarParameters.EndTime +
"&sortCol=" + this.s.dt.oInstance.fnSettings().aaSorting[0][0] +
"&sortDir=" + this.s.dt.oInstance.fnSettings().aaSorting[0][1] +
"&fileName=" + document.title + ".csv";
document.body.appendChild(iframe);
}
}
]
}
In your implementation of this, you would want to collect the selected rows and pass them in the querystring I guess by using an ID which gets pulled from a hidden column when the associated checkbox is checked.
jdadwilson