How I can aligment only one column ?
How I can aligment only one column ?
Romuald
Posts: 23Questions: 3Answers: 0
Hello,
I would like aligment my last column only ?
I try this code but this no work :
customize: function (doc) {
doc.styles.tableBodyEven.alignment = 'center'
doc.styles.tableBodyOdd.alignment = 'center'
I must define the column I think ?
Have you a sample code ?
Thank you for help
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Hi @Romuald ,
Something like this with would do the trick,
Cheers,
Colin
Hi @Colin,
Thank you for your help
I misspoke...
I would like aligment my last column center only when I export in PDF ? (See screen)
I must give the number of column ? How I can to do ?
Thank you.
Romuald
Hi @Romuald ,
This thread here should do the trick for the export column alignment.
Cheers,
Colin
Hi @Colin,
I try this code :
My problem :
- 'var rowCount = document.getElementById("tableau").rows.length;' My result is 11 lines, but I'm 226 lines.
It's because of the pagination I think... this code give me only the rows count of the first page
I'm no see my error ???
Thank you for your help
If you're using
serverSide
, then yep, that's correct, only the visible rows are exported. Otherwise, we're happy to take a look, please can you link to a test case.Cheers,
Colin
Hi @Colin,
I test option "serverside", but I have a error.
My code :
And my error :
jquery-3.3.1.js:3818 jQuery.Deferred exception: Cannot set property 'data' of null TypeError: Cannot set property 'data' of null
at sa (https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js:36:448)
at kb (https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js:37:5)
at N (https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js:29:134)
at S (https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js:31:123)
at ga (https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js:48:392)
at e (https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js:92:256)
at HTMLTableElement.<anonymous> (https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js:92:342)
at Function.each (https://code.jquery.com/jquery-3.3.1.js:354:19)
at jQuery.fn.init.each (https://code.jquery.com/jquery-3.3.1.js:189:17)
at jQuery.fn.init.m [as dataTable] (https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js:82:462) undefined
jQuery.Deferred.exceptionHook @ jquery-3.3.1.js:3818
process @ jquery-3.3.1.js:3606
setTimeout (async)
(anonymous) @ jquery-3.3.1.js:3640
fire @ jquery-3.3.1.js:3268
fireWith @ jquery-3.3.1.js:3398
fire @ jquery-3.3.1.js:3406
fire @ jquery-3.3.1.js:3268
fireWith @ jquery-3.3.1.js:3398
ready @ jquery-3.3.1.js:3878
completed @ jquery-3.3.1.js:3888
jquery-3.3.1.js:3827 Uncaught TypeError: Cannot set property 'data' of null
at sa (jquery.dataTables.min.js:36)
at kb (jquery.dataTables.min.js:37)
at N (jquery.dataTables.min.js:29)
at S (jquery.dataTables.min.js:31)
at ga (jquery.dataTables.min.js:48)
at e (jquery.dataTables.min.js:92)
at HTMLTableElement.<anonymous> (jquery.dataTables.min.js:92)
at Function.each (jquery-3.3.1.js:354)
at jQuery.fn.init.each (jquery-3.3.1.js:189)
at jQuery.fn.init.m [as dataTable] (jquery.dataTables.min.js:82)
sa @ jquery.dataTables.min.js:36
kb @ jquery.dataTables.min.js:37
N @ jquery.dataTables.min.js:29
S @ jquery.dataTables.min.js:31
ga @ jquery.dataTables.min.js:48
e @ jquery.dataTables.min.js:92
(anonymous) @ jquery.dataTables.min.js:92
each @ jquery-3.3.1.js:354
each @ jquery-3.3.1.js:189
m @ jquery.dataTables.min.js:82
h.fn.DataTable @ jquery.dataTables.min.js:164
(anonymous) @ script.js:22
mightThrow @ jquery-3.3.1.js:3534
process @ jquery-3.3.1.js:3602
setTimeout (async)
jQuery.readyException @ jquery-3.3.1.js:3826
(anonymous) @ jquery-3.3.1.js:3846
mightThrow @ jquery-3.3.1.js:3534
process @ jquery-3.3.1.js:3602
setTimeout (async)
(anonymous) @ jquery-3.3.1.js:3640
fire @ jquery-3.3.1.js:3268
fireWith @ jquery-3.3.1.js:3398
fire @ jquery-3.3.1.js:3406
fire @ jquery-3.3.1.js:3268
fireWith @ jquery-3.3.1.js:3398
process @ jquery-3.3.1.js:3622
setTimeout (async)
(anonymous) @ jquery-3.3.1.js:3640
fire @ jquery-3.3.1.js:3268
fireWith @ jquery-3.3.1.js:3398
fire @ jquery-3.3.1.js:3406
fire @ jquery-3.3.1.js:3268
fireWith @ jquery-3.3.1.js:3398
ready @ jquery-3.3.1.js:3878
completed @ jquery-3.3.1.js:3888
2script.js:40 Uncaught TypeError: Cannot set property 'alignment' of undefined
at Object.customize (script.js:40)
at s.action (buttons.html5.min.js:27)
at q (dataTables.buttons.min.js:13)
at HTMLButtonElement.<anonymous> (dataTables.buttons.min.js:14)
at HTMLButtonElement.dispatch (jquery-3.3.1.js:5183)
at HTMLButtonElement.elemData.handle (jquery-3.3.1.js:4991)
On the folders of sever, I must copy the other files that on my computer local ?
Thank you for help
Those export options look wrong - ExportPDF isn't defined anywhere in that code. This example here might help, it's doing that kind of thing.
If no joy, could you link to a running test case showing the issue so we can offer some help. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Hi @Colin,
I create a test case : live.datatables.net/leqakake/1/
Thank you for help
Romuald
Hi @Romuald ,
I just took a look at that test case, thanks for that, and it looks as expected to me - the two right-hand columns are center aligned, while all the rest are left aligned. What makes you think it's not working?
Cheers,
Colin
Hi @Colin,
I would like when I export PDF my file, that the columns "Windows 7" and "Windows 10" are aligned to center.
My problem is to calculate count total of lines :
var rowCount = document.getElementById("example").rows.length;
This code give me only the total lines of the 1er page.
Thank you for help
Romuald
Ah, ok. You can get the row count using
count()
, so something likeCheers,
Colin
Hi @Colin,
I try this function :
var rowCount = $('#example').DataTable().rows().count();
I have a good number of lines, but if I'm filtering and that the result give me 2 line, this function give me always the lines total.
Example :
How I can to have the numbers total of lines without or with search ?
Thank you for help.
Ah, ok. You can use
page.info()
.Hi @Colin,
Good
With this code, it's fine
rowCount = info.recordsDisplay + 1;
Thank you for help