PDF cell borders / criteria

PDF cell borders / criteria

solrasolra Posts: 7Questions: 0Answers: 0
edited March 2014 in TableTools
Allan,

Hope you're well! So, I know this has been asked 1000 times, and I haven't been able to find an answer, so maybe there is no solution, but I will ask in hopes there is one...

I need the borders of the table cells in the PDF document to be more prominent. Is there a style to add to a stylesheet or the swf to allow this? Also, secondly I want the 'search criteria' to also be sent to the PDF document. See: http://dev.recreationaltrailsinfo.org/database/search_results1.php?state[]=ak&countyVal=&congressDVal=&trailVal=&projVal=&project_year=&project_year2=&form_id=525625&submit=Search+the+Database. Where search criteria = Alabama.

Any assistance would be wonderful!

Thanks,
Jon

Replies

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    Hi Jon,

    There isn't an option external to the swf which allows the border to be controlled. It needs a little tweak to the AS3 code here: https://github.com/DataTables/TableTools/blob/master/as3/ZeroClipboardPdf.as#L239 .

    If you like I can compile the swf and send it over tomorrow when I'm back in the office?

    > Also, secondly I want the 'search criteria' to also be sent to the PDF document.

    As in you want only the searched rows to be in the output? You can use the oSelectorOpts option for that: http://datatables.net/extras/tabletools/button_options#oSelectorOpts . Use `filter: 'applied'` .

    Allan
  • solrasolra Posts: 7Questions: 0Answers: 0
    Allan,

    Thank you for pointing me in the right direction for the cell borders. It works for the 'alternate' rows, but every other row is still without borders.

    I have:

    var grid:Grid = new Grid(
    dataOut, /* 1. data */
    iPageWidth, /* 2. width */
    100, /* 3. height */
    new RGBColor (0xE0E0E0), /* 4. headerColor */
    new RGBColor (0xFFFFFF), /* 5. backgroundColor */
    false, /* 6. alternateRowColor */
    new RGBColor ( 0x0 ), /* 7. borderColor */
    .3, /* 8. border alpha */
    null, /* 9. joins */
    columns /* 10. columns */
    );

    Also, for the 'criteria' I mean 'Search terms'. I'd like the search terms to display at both the top of the PDF and the Print if possible. Example:

    Your Search Criteria:

    State: AK,CO

    Results row
    Results row
    Results row
    Results row
    Results row
    Results row


    Thank you!
    Jon
  • solrasolra Posts: 7Questions: 0Answers: 0
    Allan,

    I fixed the border issue. Thanks for your help.

    Search criteria question still pending. I am guessing that there is no way to add the search terms to the top of the PDF file...

    Jon
  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    Hi Jon,

    Great to hear that you've got the borders sorted out.

    Regarding the search criteria - you want to use the 'message' option. The problem you'll have initially is that it requires a string, not a function.. However, that should be relatively simple to rectify:

    On this line in TableTools ( https://github.com/DataTables/TableTools/blob/master/js/dataTables.tableTools.js#L2744 ):

    [code]
    "message:"+ oConfig.sPdfMessage +"\n"+
    [/code]

    Change it to be:

    [code]
    "message:"+ (typeof oConfig.sPdfMessage === 'function' ? oConfig.sPdfMessage() : oConfig.sPdfMessage ) +"\n"+
    [/code]

    Then simply use sPdfMessage as a function and return a string that is based on the search options. That will be used in the PDF file.

    Allan
  • solrasolra Posts: 7Questions: 0Answers: 0
    Allan,

    Thanks again for all of your help. I've been making some progress. I'm not sure if you can help me any further with the creating a function to return a string of the search criteria for the PDF file, but this is probably outside of the realm for support for this tool and more into PHP development, so no biggie.

    But I have another question / dilemma...
    On this page [http://dev.recreationaltrailsinfo.org/database/search_results1.php?state[]=co&countyVal=&congressDVal=&trailVal=&projVal=&project_year=&project_year2=&form_id=525625&submit=Search+the+Database]

    The State of Colorado for example has large description fields that I limit the display of with a javascript. However when you 'print' to PDF the javascript obviously isn't still limiting the field in the PDF file. At first I thought maybe this AlivePDF public function may solve the issue - http://alivepdf.bytearray.org/alivepdf-asdoc/org/alivepdf/pdf/PDF.html#addCellFitScale%28%29 - but am hesitant. Of course I tried to implement but got an error because I am a big dummy.

    Do you have a public function call that I can plug into the ZeroClipboard.as file that will solve this issue?

    Again, the issue is that in the PDF file, the description field is way too big (tall) and makes the PDF funky....

    Thanks Allan!

    Jon
  • solrasolra Posts: 7Questions: 0Answers: 0
    Update: Ignore part one. We are getting the search criteria string working... Still have issues with trying to limit large fields being sent to PDF.
  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    I don't immediately have a solution for that I'm afraid. I'm not sure if addCellFitScale will work to well either - its description in the API docs there is a bit lacking. I'll need to experiment a little tomorrow with some options, although looking at the generated PDF form your page, I certainly see the issue - I had a bad feeling that it might be an AlivePDF bug when a cell spans more than one page.

    This is a nasty hack, but try doubling the length of your description column in the table. That will make it wider, which should also make it wider in the pdf...

    Allan
  • solrasolra Posts: 7Questions: 0Answers: 0
    Both of these seem like possible solutions.

    http://www.datatables.net/forums/discussion/18147/fixed-width-cells-with-content-truncation-plugin/p1
    http://datatables.net/forums/discussion/10841/truncate-column-content-via-jtruncate-json/p1
  • solrasolra Posts: 7Questions: 0Answers: 0
    Allan,

    Issue solved. Thank you for your guidance...

    I have another question... Not sure if I should start a new post, so let me know if I should, but question is; when I view results in the table, change lengthmenu to a greater number, life 100, then click on a record, then hit back in my browser, I lose the 'place' I was at, meaning if I selected to view more records then the default 10, when I go back to results set I always end back at the default selection of 10, rather then the result set of 100 records per page.

    Do you understand my question, and is there an easy fix?

    Thanks,
    Jon
  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    Hi Jon,

    Excellent to hear you got a fix for the PDF issue. What was your fix in the end?

    Regarding your follow on question - it sounds like you might want to use state saving in the DataTable - bStateSave . That will restore the table state when you go back. There is also iCookieDuration which you could set to a fairly low value for this use case. In 1.10 state saving uses localStorage rather than cookies which might be an attractive option for you.

    Regards,
    Allan
This discussion has been closed.