Page 1 of 1

Some JS code for item/record page

Posted: 23 Jun 2023, 17:19
by Didou12
Hi everyone,

Here is some JS code I use on item page, so maybe it can help you. If you think my code can be improve, let me know here :)
If you have ideas to share, tell me too.
If my English is poor, just let me know too :)


- Replace 123/456/789 for your field ID.
- JS in this box is loaded at the init of the form
- Remember JS can be access with source of the page, so don't use confidential or privacy datas



  • To hide a field with a simple condition (because some kind of input field don't let you to hide the field if empty) :

Code: Select all

value = $('.form-group-123 > td').html(); //if the field is a dropdown list : "$('.form-group-123 > td > div')"
//you can also use the id of the field like : value = [123];
if(value == '') //you also can put "== '0'", or "== 'No'", "!= ''", "== '0,00'" ... depending on your value
{
  $('.form-group-123').hide(); //hide the field
}
  • To hide a field with several conditions (with a dropdown field) :

Code: Select all

type = $('.form-group-123 > td > div').html();
//you can also use the id of the field like : type = [123]; and you need to test the value ID (not the text values) in the array
let tableValues = ["Type 1", "Type 2", "Type 3"]; //array with all text values to check
if(tableValues.includes(type)) //if the field has one of those text values
{
  $('.form-group-123').hide(); //hide the field
}


Hope it can help you :)

Re: Some JS code for item/record page

Posted: 26 Jun 2023, 23:27
by s980845
Could you please add screenshots to these examples to help us better understand what they do, and whether they would be a good fit for our own projects?

Thank You.

Re: Some JS code for item/record page

Posted: 27 Jun 2023, 01:12
by Didou12
Hi :)

You can have some information in the doc : https://docs.rukovoditel.net/index.php?p=114

Fields on item page, are there to display information (in the column), so you can hide some of them with previous codes, maybe if you field is empty and you don't want to display it, or if the field has a certain value.