Hide field in table view

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
wilmira
Veteran Member
Posts: 67
Joined: 2013-07-11 18:00

Hide field in table view

Post by wilmira » 2018-07-07 00:01

I need to hide a column for non Admins groups in TV, right now, I could managed to do it by inserting this code in the mytable.php hook>

if ($memberInfo['group'] != 'Admins')
{
$options->Template = 'hooks/mdcaja_templateTV_na.html';//whic has only 6 columns instead of 7
$options->ColCaption = array("Comprobante", "No. de casa", "Fecha", "Tipo", "Concepto", "Valor");//With this I hide the column name

}
However, because the original table has 7 colunms, and I am also using column sum for one of the fields, the column sum spans longer and covers more space that the other columns in the table.

Checking the source, I can see a <td colspan=7> code, Does anybody know how can I dinamycally change to <td colspan=6> in order to correctly format my table View.

Wilfredo

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

Re: Hide field in table view

Post by pbottcher » 2018-07-07 08:16

Hi,
can you post the source you are refering to pls and a screenshot.
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.

wilmira
Veteran Member
Posts: 67
Joined: 2013-07-11 18:00

Re: Hide field in table view

Post by wilmira » 2018-07-09 15:53

Thank you Pbottcher,

These are the screenshots
Attachments
escondercol.png
escondercol.png (84.46 KiB) Viewed 6391 times
hidecolumns.jpg
hidecolumns.jpg (92.85 KiB) Viewed 6391 times

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

Re: Hide field in table view

Post by pbottcher » 2018-07-09 20:17

Hi,

I don't think changing the col-span would solve your problem. I think the sum at the end still knows about you "hidden column" and hence it is still displayed.
In order to change this you can add the following to the mytable_header function:

Code: Select all

	function mytable_header($contentType, $memberInfo, &$args){
		$header='';

		switch($contentType){
			case 'tableview':
                                       if ($memberInfo['group'] != 'Admins') 
                                       {
					$header='<%%HEADER%%><script>
							$j(function () {
								$j(\'.<YOUR_HIDDEN_COLUMN_NAME\').hide();
							});
						 </script>';
                                       }
				break;
                         case .....
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.

wilmira
Veteran Member
Posts: 67
Joined: 2013-07-11 18:00

Re: Hide field in table view

Post by wilmira » 2018-07-10 21:03

Hi again and thank you for your answer.

I have tried your code but this will just hide the values of the seventh column. I had remove this code from mytable.php hook:

$options->ColCaption = array("Comprobante", "No. de casa", "Fecha", "Tipo", "Concepto", "Valor");//With this I hide the column name

And then I applied your code and the result is that it only hides the values of the 7th code. I attach a screenshot below.

You are right that the sum at the end is spaning to the 7th column, but the column that knows that there are still seven columns is the one that counts the records. So to solve the problem I think we need to dinamycally replace the colspan to 6 on that line of code.

Thanks again for your help.

Wilfredo
Attachments
hidecolumns2.png
hidecolumns2.png (46.29 KiB) Viewed 6368 times

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

Re: Hide field in table view

Post by pbottcher » 2018-07-10 21:12

Hi,
you should not remove your code, just add mine and that should work together.
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.

wilmira
Veteran Member
Posts: 67
Joined: 2013-07-11 18:00

Re: Hide field in table view

Post by wilmira » 2018-07-10 21:16

Sorry Pbotcher,

You were actually right, I have tried the code locally and modified the colspan to 6 and the issue is not actually there, you are totally right is should be in the sum row.

Wilfredo

wilmira
Veteran Member
Posts: 67
Joined: 2013-07-11 18:00

Re: Hide field in table view

Post by wilmira » 2018-07-10 21:36

I found it, it was there in the sum:

<tr class="success"><td class="text-center"><strong>&sum;</strong></td><td class="mdcaja-compro_mdcaja"></td><td class="mdcaja-numcasa_mdcaja"></td><td class="mdcaja-fecha_mdcaja"></td><td class="mdcaja-tipo_mdcaja"></td><td class="mdcaja-concep_mdcaja"></td><td class="mdcaja-valor_mdcaja text-right">$58.00</td><td class="mdcaja-vecino_mdcaja"></td></tr>

The last column is still there, the one that is hidden.

Now It is only a matter to find a way to remove it from the generate table_view.php

wilmira
Veteran Member
Posts: 67
Joined: 2013-07-11 18:00

Re: Hide field in table view

Post by wilmira » 2018-07-10 21:40

I did try my code together with yours and nothing happened so I remove mine in order try only yours

wilmira
Veteran Member
Posts: 67
Joined: 2013-07-11 18:00

Re: Hide field in table view

Post by wilmira » 2018-07-10 22:02

I am Back again, I finally make it work, your code was right, it was the "<" sign I did not notice it was there.

Sorry for all the misunderstanding.

Wilfredo

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

Re: Hide field in table view

Post by Moh Youba » 2021-07-30 18:59

Hello

Trying to do the same but unfortunatelly my coding level is not strong enought to understand. can you please share full code et details.

Thank you

Post Reply