Created
May 4, 2021 19:46
-
-
Save YuriyZaletskyy/698abc111595a54f670d0cd85a832d49 to your computer and use it in GitHub Desktop.
Dynamic Selector Functionality
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace MyProject | |
{ | |
public class APInvoiceEntryExt : PXGraphExtension<APInvoiceEntry> | |
{ | |
public PXSelect<MyCommand> Commands; | |
public PXSelect<GLTran> GLTrans; | |
public PXSelect<FixedAsset> FixedAssets; | |
protected void MyCommand_CommandData_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e) | |
{ | |
var row = (MyCommand)e.Row; | |
if (row == null) | |
return; | |
PXFieldState state = PXFieldState.CreateInstance(e.ReturnState, | |
typeof(string), false, true, 1, null, null, null, typeof(MyCommand.commandData).Name); | |
e.ReturnState = state; | |
var id = (int)row.CommandID; | |
if (id == 0) | |
{ | |
state.ViewName = nameof(FixedAssets); | |
state.DescriptionName = nameof(FixedAsset.description); | |
state.FieldList = new string[] | |
{ | |
nameof(FixedAsset.assetID), | |
nameof(FixedAsset.description), | |
nameof(FixedAsset.assetTypeID), | |
nameof(FixedAsset.assetCD) | |
}; | |
var selectorCache = Base.Caches<FixedAsset>(); | |
state.HeaderList = new string[] | |
{ | |
PXUIFieldAttribute.GetDisplayName<FixedAsset.assetID>(selectorCache), | |
PXUIFieldAttribute.GetDisplayName<FixedAsset.description>(selectorCache), | |
PXUIFieldAttribute.GetDisplayName<FixedAsset.assetTypeID>(selectorCache), | |
PXUIFieldAttribute.GetDisplayName<FixedAsset.assetCD>(selectorCache), | |
}; | |
} | |
else | |
{ | |
state.ViewName = nameof(GLTrans); | |
state.DescriptionName = nameof(GLTran.tranDesc); | |
state.FieldList = new string[] | |
{ | |
nameof(GLTran.module), nameof(GLTran.lineNbr), nameof(GLTran.batchNbr), | |
nameof(GLTran.accountID), nameof(GLTran.tranDesc), nameof(GLTran.branchID) | |
}; | |
var selectorCache = Base.Caches<GLTran>(); | |
state.HeaderList = new string[] | |
{ | |
PXUIFieldAttribute.GetDisplayName<GLTran.module>(selectorCache), | |
PXUIFieldAttribute.GetDisplayName<GLTran.lineNbr>(selectorCache), | |
PXUIFieldAttribute.GetDisplayName<GLTran.batchNbr>(selectorCache), | |
PXUIFieldAttribute.GetDisplayName<GLTran.accountID>(selectorCache), | |
PXUIFieldAttribute.GetDisplayName<GLTran.tranDesc>(selectorCache) | |
}; | |
} | |
state.DisplayName = PXUIFieldAttribute.GetDisplayName<MyCommand.commandData>(cache); | |
state.Visible = true; | |
state.Visibility = PXUIVisibility.Visible; | |
state.Enabled = true; | |
} | |
public PXAction<PX.Objects.AP.APInvoice> CommandButton; | |
[PXButton(CommitChanges = true)] | |
[PXUIField(DisplayName = "Command Button")] | |
protected void commandButton() | |
{ | |
Commands.AskExt(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @YuriyZaletskyy
Can you send the CommandData field code in MyCommand DAC.
Thanks.