Align caption text to center of table

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

Align caption text to center of table

Post by Moh Youba » 2019-07-07 10:37

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 4922 times

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Align caption text to center of table

Post by pbottcher » 2019-07-07 13:18

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.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

Re: Align caption text to center of table

Post by Moh Youba » 2019-07-07 14:05

Hello

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

Thank you

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Align caption text to center of table

Post by pbottcher » 2019-07-07 15:21

Hi,

put it in hooks/footer-extras.php

Code: Select all

<script>
$j("thead tr th").each(function() { $j(this).addClass("text-center") })
</script>
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

Re: Align caption text to center of table

Post by Moh Youba » 2019-07-07 15:29

humm !!! I put in the hooks/footer-extars.php but still align in left
hooks-1.jpg
hooks-1.jpg (13.11 KiB) Viewed 4907 times
hooks-2.jpg
hooks-2.jpg (41.93 KiB) Viewed 4907 times

Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

Re: Align caption text to center of table

Post by Moh Youba » 2019-07-07 15:32

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,

User avatar
aarlauskas
Veteran Member
Posts: 127
Joined: 2019-04-28 18:03
Location: Medway, UK

Re: Align caption text to center of table

Post by aarlauskas » 2020-11-16 21:48

Thanks Pascal, good to know! Is there a way to point this out to specific table?

User avatar
zibrahim
Veteran Member
Posts: 137
Joined: 2020-01-28 18:30
Location: Malaysia

Re: Align caption text to center of table

Post by zibrahim » 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.
Zala.
Appgini 24.10.1579, MacOS 14.3.1 Windows 11 on Parallels.

User avatar
aarlauskas
Veteran Member
Posts: 127
Joined: 2019-04-28 18:03
Location: Medway, UK

Re: Align caption text to center of table

Post by aarlauskas » 2020-11-17 06:47

Thanks Zala! I'll try later on and let you know. Appreciate your input!

User avatar
aarlauskas
Veteran Member
Posts: 127
Joined: 2019-04-28 18:03
Location: Medway, UK

Re: Align caption text to center of table

Post by aarlauskas » 2020-11-17 15:41

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.

User avatar
zibrahim
Veteran Member
Posts: 137
Joined: 2020-01-28 18:30
Location: Malaysia

Re: Align caption text to center of table

Post by zibrahim » 2020-11-18 00:04

Hmmm...It is working for me....how strange.....
Zala.
Appgini 24.10.1579, MacOS 14.3.1 Windows 11 on Parallels.

ltlow
Posts: 15
Joined: 2021-07-29 09:37

Re: Align caption text to center of table

Post by ltlow » 2021-08-18 01:39

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.

Post Reply