tableTools Button Implementation

tableTools Button Implementation

jdadwilsonjdadwilson Posts: 80Questions: 14Answers: 1
edited March 2014 in TableTools
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


  • allanallan Posts: 61,584Questions: 1Answers: 10,084 Site admin
    You would think this would be easy... However, it would actually require a fair bit of intervention in the TableTools code I'm afraid. The way the print works is that it takes the table node (not a clone of it, or a copy of the data) and reformats that for print display.

    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...

  • robertbrowerrobertbrower Posts: 158Questions: 1Answers: 0
    edited March 2014
    I have a page where there is a data table that uses server side paging. But my user's wanted the CSV export to export all of the filtered data and not just page 1 or 2 of however many pages there happens to be. To do this, i handle the click event of the table tools button. In this handler, I create a url containing query string parameters which specify which rows to export. I set the URL of a hidden iframe to this url which in my implementation happens to be a generic handler.

    , "oTableTools": {
    "aButtons": [
    "sExtends": "ajax"
    , "sButtonText": "CSV"
    , "fnClick": function () {
    var iframe = document.createElement('iframe'); = "0px"; = "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";

    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.
  • jdadwilsonjdadwilson Posts: 80Questions: 14Answers: 1
    Thanks for the reply... Your suggestion is pretty much what I figured I would have to do.

This discussion has been closed.