Skip to content

Instantly share code, notes, and snippets.

@BrianMRO
Last active February 9, 2021 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrianMRO/21ccb41f5c6e4065944e2199634b470a to your computer and use it in GitHub Desktop.
Save BrianMRO/21ccb41f5c6e4065944e2199634b470a to your computer and use it in GitHub Desktop.
Dynamic Lists
protected void _(Events.RowSelected<XXMyDAC> e)
{
XXMyDAC row = x.Row;
if(*condition*) // Substitute your conditional logic here
{
SelectableValues2 listattr = new SelectableValues2();
PXStringListAttribute.SetList<XXMyDAC.myField>
(e.Cache, row, listattr.AllowedValues, listattr.AllowedLabels);
}
}
public class SelectableValues : PXStringListAttribute
{
public class ListAttribute : PXStringListAttribute
{
public ListAttribute() : base(
new[]
{
Pair(MyValue1, Messages.MyLabel1),
Pair(MyValue2, Messages.MyLabel2),
Pair(MyValue3, Messages.MyLabel3),
})
{ }
}
}
public class SelectableValues1 : PXStringListAttribute
{
public string[] AllowedLabels = new string[]
{
Messages.MyLabel1,
Messages.MyLabel2
};
public string[] AllowedValues = new string[]
{
MyValue1,
MyValue2
};
}
public class SelectableValues2 : PXStringListAttribute
{
public string[] AllowedLabels = new string[]
{
Messages.MyLabel1,
Messages.MyLabel3
};
public string[] AllowedValues = new string[]
{
MyValue1,
MyValue3
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment