Show and Hide Grids on the Fly

Hi Everyone,

Sometimes you need to show user interface differently depend on parameters selected. Here I want to show you an approach where you can show different grids depend on parameters selected in filter.

You may need different grids in the following cases:

  • If have different data access classes (tables) to show.
  • If you need to have different grids layout depend on parameters.
  • If you  need to to have different columns configurations.

So the plan is the following:

      1. Have 2 different DACs. We need it to have different caches, as viability settings are linked to cache.
        1. public class DetailsTableA : IBqlTable
                public abstract class fieldA: IBqlField { }  
                [PXUIField(DisplayName = "Field A")]
                public virtual String FieldA { get; set; }  
        2. public class DetailsTableB : IBqlTable
                public abstract class fieldB: IBqlField { }  
                [PXUIField(DisplayName = "Field B")]
                public virtual String FieldB { get; set; }  
      2. Have 2 different DataViews to link grids to different DACs.
        1. public PXFilter<DetailsTableADetailsViewA;
        2. public PXFilter<DetailsTableBDetailsViewB;
      3. Have 2 different grids in the user interface.
  1. In the RowSelected Event of Form choose one or another grid and using Cache.AllowSelect = true/false choose what grid should be visible.
public void MasterTable_RowSelected(PXCache sender, 
      PXRowSelectedEventArgs e)
      MasterTable row = (MasterTable)e.Row;
      bool val =  row == null || row.Status == "A";
      DetailsViewA.Cache.AllowSelect = val;
      DetailsViewB.Cache.AllowSelect = !val;          

Acumatica will automatically sync grid visibility and hide/show grids dynamically.

Acumatica two Grids in UI

You can see full code here:

Have a nice development!

Leave a Reply

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