Page 1 of 1

Align caption text to center of table

Posted: 2019-07-07 10:37
by Moh Youba
Hello

In AppGini, we can align text by choosing the desired alignment, but only text on the table can be center. I want to center the caption text.

My English is not very good to explain what I need, please see attached picture to help.

Best regards,
center_caption_fields.jpg
center_caption_fields.jpg (65.9 KiB) Viewed 4934 times

Re: Align caption text to center of table

Posted: 2019-07-07 13:18
by pbottcher
Hi,
you can use

Code: Select all

$j("thead tr th").each(function() { $j(this).addClass("text-center") })
to set the header to center.

This applies to all table header, so if you have multiple you may need to select the one you want to control.

Re: Align caption text to center of table

Posted: 2019-07-07 14:05
by Moh Youba
Hello

Thank you. Yes I want to apply to all tables.
Please, where to put this code

Thank you

Re: Align caption text to center of table

Posted: 2019-07-07 15:21
by pbottcher
Hi,

put it in hooks/footer-extras.php

Code: Select all

<script>
$j("thead tr th").each(function() { $j(this).addClass("text-center") })
</script>

Re: Align caption text to center of table

Posted: 2019-07-07 15:29
by Moh Youba
humm !!! I put in the hooks/footer-extars.php but still align in left
hooks-1.jpg
hooks-1.jpg (13.11 KiB) Viewed 4919 times
hooks-2.jpg
hooks-2.jpg (41.93 KiB) Viewed 4919 times

Re: Align caption text to center of table

Posted: 2019-07-07 15:32
by Moh Youba
ok working fine.
first I put inside <?php ... ?>
now I put oustise and it is working fine
thank you for your great help and support

You give me also opportunity to learn new thing

best regards,

Re: Align caption text to center of table

Posted: 2020-11-16 21:48
by aarlauskas
Thanks Pascal, good to know! Is there a way to point this out to specific table?

Re: Align caption text to center of table

Posted: 2020-11-17 01:41
by zibrahim
Try putting Pascal's code in hooks/TABLENAME-tv.js
(please note that it is ...-tv.js not ...-dv.js)

Code: Select all

// To make table heading center
$j(function () {
    $j("thead tr th").each(function () {
        $j(this).addClass("text-center");
    });
});
if you hate the header text wrapping, you can also add nowrap class like the following

Code: Select all

// To make table heading center and no wrapping
$j(function () {
    $j("thead tr th").each(function () {
        $j(this).addClass("text-center text-nowrap");
    });
});
please note that your entire table width may be looooooooger... :)

Good luck and stay safe.

Re: Align caption text to center of table

Posted: 2020-11-17 06:47
by aarlauskas
Thanks Zala! I'll try later on and let you know. Appreciate your input!

Re: Align caption text to center of table

Posted: 2020-11-17 15:41
by aarlauskas
Hi Zala, I have created new my_table_name-tv.js in hooks folder and dropped your code in there, but it doesn't seem to be doing anything :roll: Thanks for your help Buddy.

Re: Align caption text to center of table

Posted: 2020-11-18 00:04
by zibrahim
Hmmm...It is working for me....how strange.....

Re: Align caption text to center of table

Posted: 2021-08-18 01:39
by ltlow
zibrahim wrote:
2020-11-17 01:41
Try putting Pascal's code in hooks/TABLENAME-tv.js
(please note that it is ...-tv.js not ...-dv.js)

Code: Select all

// To make table heading center
$j(function () {
    $j("thead tr th").each(function () {
        $j(this).addClass("text-center");
    });
});
if you hate the header text wrapping, you can also add nowrap class like the following

Code: Select all

// To make table heading center and no wrapping
$j(function () {
    $j("thead tr th").each(function () {
        $j(this).addClass("text-center text-nowrap");
    });
});
please note that your entire table width may be looooooooger... :)

Good luck and stay safe.
Although it is working, but after this I cant hide any column anymore, all column maintain showing.