I need Help Please (dataTable align

I need Help Please (dataTable align

jfri_2007jfri_2007 Posts: 25Questions: 6Answers: 0
edited September 2015 in Free community support

hello people, i have a problem, when i use the button print in dataTable, i will explain it, i have my dataTable with values align like this :

"columnDefs": [
{className: 'text-center', targets: [0]},
{className: 'text-center', targets: [1]},
{className: 'text-center', targets: [2]},
{className: 'text-right', targets: [3]},
{className: 'text-right', targets: [4]},
{className: 'text-right', targets: [5]},
{className: 'text-right', targets: [6]},

but when i click the button print , the preview print`s datatables is text-left by default, i need text-right .(that means i want to show the print(my dataTable) like in the page)
If somebody can help me, i will be grateful with you all,
sorry for my English, i am Venezuelan

Answers

  • jfri_2007jfri_2007 Posts: 25Questions: 6Answers: 0

    like that in the 5th column : is center align, and when i press the button print the preview is the same like the page
    http://legacy.datatables.net/release-datatables/extras/TableTools/swf_path.html

  • jfri_2007jfri_2007 Posts: 25Questions: 6Answers: 0

    but there is not a code example

  • jfri_2007jfri_2007 Posts: 25Questions: 6Answers: 0
    edited September 2015

    when i print it loses the align.

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75
    edited September 2015

    Are you using the legacy TableTools?

    Also, can you please use formatting when you post code? Thats impossible to read, unless you're a computer :-D

    Can I view the example you have somewhere? Is it publicly accessible?
    If not, can you throw it on live.datatables.net?

    Thank you

  • jfri_2007jfri_2007 Posts: 25Questions: 6Answers: 0

    i am not using legacy, this was just an example of how i want to have my table

  • jfri_2007jfri_2007 Posts: 25Questions: 6Answers: 0
    edited September 2015

    If someone needs it , i got the solution, when you print the dataTAble does not mantein the style, alignment, etc. then you need to add the necesary classes in the customize( look for the dataTable web examples ) :

    $(win.document.body).find('td:nth-child(7)').addClass('text-right');

    where number 7 is the column number , my class was to align to the right text

    ...

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75

    Oh, so you mean style it in the dom? ok

    To make that jQuery selector a little more efficient, you can do

    $('#data-table').find('tbody').find('tr').find('td:nth-child(7)').addClass('text-right');
    
  • jfri_2007jfri_2007 Posts: 25Questions: 6Answers: 0

    oh good ty, I am trying to print the total value together with the table in the same page, I have the total value in a label outside the DataTable, any idea how could I reach this?, I am thinking about multi-message (print customize), but I don't know how to do it..

This discussion has been closed.