Dynamic Drop-Down Control

Hi Everyone,

Usually Acumatica Drop-Down controls have fixed lists of values. Of course you can use PXStringListAttribute.SetList<…>(…) method do change list of values dynamically, but how to make it more handy.

The way I recommend you is to create an attribute that can encapsulate all the field related logic, so to use it you can just put the attribute on the proper place.
So the plan:

  1. Create an attribute that will be inherited from PXStringList and provide the values
  2. Create IPrefetchable class that can be automatically load all possible list from DB and cache it. In the same time Acumatica will auto-reset when the linked table is changed. This is really great performance optimization. Read more about caching data with database slots here.
  3. Use PXDatabase.GetSlot to retrieve the data from memory. If data is not yet cached or changed Acumatica platform will automatically will call Prefertch method to refresh data.
  4. Subscribe to RowSelected event and adjust the list using SetList method.
  5. Apply attribute on the field in the DAC
  6. (Optional) if your drop-down is located in the grid, make sure that your grid has MatrixMode=true

Please see the full example here:

Really hope it helps and have a nice development!

2 Replies to “Dynamic Drop-Down Control”

Leave a Reply

Your email address will not be published. Required fields are marked *