hide rows in javascript - Master/Details

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
FelipeRau12
User
Posts: 45

hide rows in javascript - Master/Details

Post by FelipeRau12 »

hello,

I would like to know how I can make to make an invisible field via javascript or html before the screen structure is displayed or constructed.

My scenario is the following I have a screen with many field, and used the autofill if using the invisible option via php the autofill does not work, at the same time did a function in javascript that I run in Table-Specific -> Add / Copy Page -> Startup Script works fine but the problem is that it has a visual effect. When clicking on the add screen it mounts the whole structure after a while it runs the java script that makes the fields invisible only in this process it has a visual effect of scrolling the other fields. Master/Details i need hide columns in details.

$('#tbl_nfeitensgrid tr').each(function(){
$(this).children('td').eq(3).hide();
$(this).children('th').eq(3).hide();


$(this).children('td').eq(4).hide();
$(this).children('th').eq(4).hide();
   
$(this).children('td').eq(5).hide();
$(this).children('th').eq(5).hide();

$(this).children('td').eq(6).hide();
$(this).children('th').eq(6).hide();
  
$(this).children('td').eq(7).hide();
$(this).children('th').eq(7).hide();
   
$(this).children('td').eq(8).hide();
$(this).children('th').eq(8).hide();
   
$(this).children('td').eq(9).hide();
$(this).children('th').eq(9).hide();
   
$(this).children('td').eq(10).hide();
$(this).children('th').eq(10).hide();
   
$(this).children('td').eq(11).hide();
$(this).children('th').eq(11).hide();

$(this).children('td').eq(12).hide();
$(this).children('th').eq(12).hide();

});

Would you have an option to make invisil via html or javascript before it set up the whole structure so that it does not act this scrolling from the other fields?

My question is the time at which the script runs. In the Table-Specific path -> Add / Copy Page -> Startup as far as I understand. It would be the end after he has loaded the whole page he runs the code that is there. Think of the scenario I have a details table with several fields to the point of triggering the scroll bar, after it executes the jquery script to hide the fields it resizes the page again and removes the scroll bar but this gets too bad to the user of the system.

I wonder if there is another point where I can run the javascript script before the page is displayed to the user.

I can not do in php since I fill that field with autofill if hiding with php does not work autofill

Thanks

Felipe


kirondedshem
User
Posts: 642

Post by kirondedshem »

I think I ve found a beter way is to add css style setting to hide the controlls even before the page thinks of loading. And the only place where I could add the css setting is in page_head which I know is called by all pages beofre they even load. So I check if the page being loaded is the master add/edit page, Then we add the equivalent of hiding the elements using jquery but written in plain css. And since we only add this during a specific page it should not affect other pages. The code you place in page_head is put in header file so I think it should be ok

LOGIC:again we look for a specific common attribute of elements we want to hide and attach hidden attribute on them. For tis case am following the data-name attribute whch both column eader and controlls have in common
go to page _head and add the following code,
<?php
//check if we are on master add page
if(CurrentPage()->TableName == "master_table" && (CurrentPage()->PageID == "add" || CurrentPage()->PageID == "edit"))
{
//write css to hide all columns on detail page
?>
<style type="text/css">
[data-name="field_name"]
{
display: none;
visibility: collapse;
}
</style>
<?php } ?>

Try and see if it works for you


FelipeRau12
User
Posts: 45

Post by FelipeRau12 »

Thanks you feedblack

was searching the help file. You have an option

Custom Templates -> Table-Specific -> Add / Copy Page -> Custom Tamplate.

Do you know this option will be able to solve the problem using this option?

Thanks


kirondedshem
User
Posts: 642

Post by kirondedshem »

custom template does not support the detail tables, it will work the master form but not the detail forms below it, the only way currently is to customise it using jquery which you say has a undesired effect,

Did the last solution of putting the styles to hide the field in page_head not work as well


Post Reply