Page 1 of 1

Hide a Field when Add Record

Posted: Sun Mar 06, 2022 7:26 pm
by shahparzsoft

I want to hide a field when Add Record, and Show with the following event.

Show event (mentioned below) works fine, but how to Hide when Add:

{ // keys = event types, values = handler functions
	"change": function(e) {
		// Your code
		var $row = $(this).fields();
		if (this.value == 8) {
			$row["amount_recvd"].visible(true);
		}
	}
}

Please help.


Re: Hide a Field when Add Record

Posted: Mon Mar 07, 2022 9:38 am
by arbei

You may hide it with Startup Script, e.g.

$("#r_amount_recvd").hide(); // Select the row, assumed Add page

(Right click the row in Chrome and select "Inspect" to check the actual id.)


Re: Hide a Field when Add Record

Posted: Mon Mar 07, 2022 1:29 pm
by shahparzsoft
  1. $("#x_amount_recvd").hide();
    this works like #x not #r.
  2. It only hides the field not the caption
  3. it didn't showing with the below function:
    { // keys = event types, values = handler functions
    "change": function(e) {
    // Your code
    var $row = $(this).fields();
    if (this.value == 8) {
    $row["amount_recvd"].visible(true);
    }
    }
    }

Re: Hide a Field when Add Record

Posted: Mon Mar 07, 2022 2:18 pm
by arbei

arbei wrote:

$("#r_amount_recvd").hide(); // Select the row, assumed Add page

  1. In Add/Edit, the row of each field is named by "r_<fieldname>". Right click the element and select "Inspect" in Chrome to check the id of HTML elements. If you use "#x_amount_recvd", you only hide the input, not the row (including caption).
  2. Startup Script and Client Side Script are independent, you need to use both.

Re: Hide a Field when Add Record

Posted: Mon Mar 07, 2022 2:24 pm
by shahparzsoft

arbei wrote:

  1. Startup Script and Client Side Script are independent, you need to use both.

Cannot understand this line ? please elaborate ...


Re: Hide a Field when Add Record

Posted: Mon Mar 07, 2022 2:49 pm
by arbei

shahparzsoft wrote:

  1. it didn't showing with the below function:
    { // keys = event types, values = handler functions ...

That is Client Side Script for fields, it is generated in userevent.js. Client/Startup Scripts are generated in userfn.js. They are different.


Re: Hide a Field when Add Record

Posted: Thu Mar 10, 2022 6:43 pm
by shahparzsoft

this works fine in simple add page (Client Script->Table Specific->Add/Copy Page->Startup Script:

$("#conditional").hide();

But not works in modal add page.

Please help.


Re: Hide a Field when Add Record

Posted: Fri Mar 11, 2022 9:12 am
by arbei

What is "#conditional"?


Re: Hide a Field when Add Record

Posted: Fri Mar 11, 2022 4:35 pm
by mobhar

shahparzsoft wrote:

But not works in modal add page.

Since the Modal dialog for Add page is displayed from List Page, then you may put also that code in Startup Script of List Page. In addition, make sure to include the Modal css selector/id to your css selector above


Re: Hide a Field when Add Record

Posted: Tue Feb 20, 2024 7:36 pm
by philmills

I hit the same issue.
I have a field with "allow add" enabled, but in the modal dialogue for adding, there are fields showing that have actually been disabled generally for add.
Why doesn't allow add modal dialogue obey the field settings for the table I'm adding to?
How can i hide the fields?


Re: Hide a Field when Add Record

Posted: Tue Feb 20, 2024 8:06 pm
by mobhar

If you meant it is Add Option Page (not normal Add Page), then in v2024 it has its own Server Events and its own Client Scripts. It is seperated between normal Add Page and Add Option Page.


Re: Hide a Field when Add Record

Posted: Tue Feb 20, 2024 9:38 pm
by philmills

Got it, same in v2023