Forums: Conditional formatting on edit page - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Conditional formatting on edit page Rate Topic: -----

#1 User is offline   timnorvel 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 290
  • Joined: 21-September 07
  • Gender:Male
  • Location:Minnesota, USA

Posted 10 April 2019 - 04:45 PM

Hi all,

I am trying to do some conditional formatting based on this from the help file:

https://xlinesoft.co...round_color.htm


I need to do this on an edit page and only if 2 fields don't match. So, in the "Process record values" event I have this code:

if (values["AccountNumber"].ToString() != values["NewAccountNumber"].ToString() )
{
	record["NewAccountNumber_css"] = "background: red;";
}


When I build the project I get the error "The name 'record' does not exist in the current context". So I gather this code from the help file isn't meant for this event. So how do I change the formatting on an edit page based on the condition of 2 fields not matching? And I don't need this done dynamically (like when a value changes on the page), I just need it when the page loads.

Thanks,
Tim
0

#2 User is offline   admin 

  • Administrator
  • PipPipPip
  • Group: Admin
  • Posts: 16451
  • Joined: 03-February 03
  • Gender:Male

Posted 10 April 2019 - 07:24 PM

"After Record Processed" and "Process record values" are two different events. First one designed to work on List/Print pages while second runs on Add/Edit/View pages and serves a totally different purpose.

Your best option to make changes like this is to use Javascript onload event. I'm not 100% sure though what exactly you want to change as there is no table cell on the Edit page.
Best regards,
Sergey Kornilov
0

#3 User is offline   timnorvel 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 290
  • Joined: 21-September 07
  • Gender:Male
  • Location:Minnesota, USA

Posted 11 April 2019 - 01:55 PM

Yes, I realized all of this shortly after I posted. And I will change the formatting on the font instead of a cell.

Here is what I'm thinking in the Javascript onload event:

var ctrlBN = Runner.getControl(pageid,'BusinessName'); 
var ctrlNBN = Runner.getControl(pageid,'NewBusinessName'); 

if (ctrlBN != ctrlNBN) {
	ctrlNBN.addStyle(color:red);
}


Unfortunately there are a lot of fields on this page, so there will be much typing. All corresponding fields are named the same with "New" added in front. I wonder if there's a way to loop through all fields so I don't have to type each one... ?

Thanks,
Tim
0

#4 User is offline   admin 

  • Administrator
  • PipPipPip
  • Group: Admin
  • Posts: 16451
  • Joined: 03-February 03
  • Gender:Male

Posted 12 April 2019 - 11:31 PM

To get all the controls of the table, you need to pass only the table name as the argument:

var ctrlArr = Runner.controls.ControlManager.getAt(tableName);



More info (see first example):
https://xlinesoft.co...dvalidation.htm
Best regards,
Sergey Kornilov
0

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users