How to display Green image status

Hello everybody,

I want to leave a short note regarding showing successful validation of some operation. Background is the following. Imagine, that you need somehow validate value entered in some checkbox. And in case if validation is successful, you'd like to show green sign near your text entry. I mean something like this:

How to achieve it?

1. Create field in DAC or DAC extension similar to shown below:

public abstract class creditGreenStatus : BqlBool.Field<creditGreenStatus> { }
[PXUIField(DisplayName = "", Visible = false)]
[PXBool]
[PXDefault(false, PersistingCheck = PXPersistingCheck.Nothing)]
public bool? CreditGreenStatus { getset; }

2. Create markup on the page like this:

<px:PXLayoutRule runat="server" ID="CstPXLayoutRule8" Merge="True" />
<px:PXTextEdit runat="server" CommitChanges="True" DataField="UsrCreditCard" ID="CstPXTextEdit3" />
<px:PXCheckBox runat="server" ID="CstPXCheckBox9" DataField="CreditGreenStatus" RenderStyle="Button">
	<CheckImages Normal="main@Success" />
	<UncheckImages Normal="main@Success" /></px:PXCheckBox>

3. In case of successful validation execute line similar to below:

PXUIFieldAttribute.SetVisible<SOOrderExt.creditGreenStatus>(docgraph.Document.Cache, docgraph.Document.Current, true);

And then finally Build -> Refresh page, and after validation you'll see nice green checkbox

Summary

With those three steps: dac extension, layout rule + textbox rendered as button and setting visible to true you'll get nice visualization of cases when field has proper or improper value.

No Comments

Add a Comment