Parent-Child Records - Hide tabs without Associated Records

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
TheNoLifer
Veteran Member
Posts: 67
Joined: 2015-06-06 12:10

Parent-Child Records - Hide tabs without Associated Records

Post by TheNoLifer » 2016-11-29 18:36

All,

Latest release of appgini!

Here's an example row from my application - a record from my Persons table;

https://ada.abernyte.org/ContentItem_Pe ... ectedID=45

If you scroll to the bottom, you can see the Child/Parent relationships of this table - this guy has associated records in a number of other tables in my system. This is all good.

I'm wondering, however, is there a way to hide the tabs where he doesn't have associated records? For example, He doesn't have any associated "Person Images" or "Census" records, yet they're still shown (albeit with a "No Matches Found" message) - could code modifications be made to hide these buttons/tabs altogether (until an associated record is added, then they'd appear)?

Any ideas?

Thanks!

DevGiu
AppGini Super Hero
AppGini Super Hero
Posts: 151
Joined: 2016-05-27 09:08

Re: Parent-Child Records - Hide tabs without Associated Records

Post by DevGiu » 2016-11-30 09:11

If you don't want to do Ajax querys to know the number of rows, you can always count table rows (taking in consideration header and footer), on your Jquery ready to do something like this.

Code: Select all


$j(function(){ // jquery ready

if ($j('#panel_Person_Images-person_id tr').length<=2) { // If returned tr is 2 or less, then there aren't records.
   $j('#panel_Person_Images-person_id').remove(); // Remove panel
   $j('#tab_Person_Images-person_id').parent().remove(); // Remove tab
}

}); // end jquery ready
/Giuseppe
Professional Outsourcing Services

TheNoLifer
Veteran Member
Posts: 67
Joined: 2015-06-06 12:10

Re: Parent-Child Records - Hide tabs without Associated Records

Post by TheNoLifer » 2016-11-30 15:15

Thanks for the reply - interesting code. In which file should this be, though? Template?

Thanks!

DevGiu
AppGini Super Hero
AppGini Super Hero
Posts: 151
Joined: 2016-05-27 09:08

Re: Parent-Child Records - Hide tabs without Associated Records

Post by DevGiu » 2016-11-30 15:22

I never touch templates or files generated by appgini. This way I don't have to take care about my files being overwrited by AppGini.
You can do this echoing from PHP (_dv hook) or more elegant and structured, on a magic file. For example, for your table, the magic file should be
hooks/ContentItem_Persons-dv.js
/Giuseppe
Professional Outsourcing Services

TheNoLifer
Veteran Member
Posts: 67
Joined: 2015-06-06 12:10

Re: Parent-Child Records - Hide tabs without Associated Records

Post by TheNoLifer » 2016-11-30 19:55

Thanks Giuseppe! I will have to play with it and see what I can do. Thanks for help.

Post Reply