Page 1 of 1

Hide field in table view

Posted: 2018-07-07 00:01
by wilmira
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

Re: Hide field in table view

Posted: 2018-07-07 08:16
by pbottcher
Hi,
can you post the source you are refering to pls and a screenshot.

Re: Hide field in table view

Posted: 2018-07-09 15:53
by wilmira
Thank you Pbottcher,

These are the screenshots

Re: Hide field in table view

Posted: 2018-07-09 20:17
by pbottcher
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 .....

Re: Hide field in table view

Posted: 2018-07-10 21:03
by wilmira
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

Re: Hide field in table view

Posted: 2018-07-10 21:12
by pbottcher
Hi,
you should not remove your code, just add mine and that should work together.

Re: Hide field in table view

Posted: 2018-07-10 21:16
by wilmira
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

Re: Hide field in table view

Posted: 2018-07-10 21:36
by wilmira
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

Re: Hide field in table view

Posted: 2018-07-10 21:40
by wilmira
I did try my code together with yours and nothing happened so I remove mine in order try only yours

Re: Hide field in table view

Posted: 2018-07-10 22:02
by wilmira
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

Re: Hide field in table view

Posted: 2021-07-30 18:59
by Moh Youba
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