Skip to main content
Solved

Smart Panel grid with Drop down not working properly

  • January 6, 2026
  • 12 replies
  • 98 views

Forum|alt.badge.img

Hi,

I have a smart panel with unbound DAC with single record. There is a dropdown field in this smart panel grid. User can manually select a value from this dropdown field. The problem is the user selected value not getting when I click OK button. I tried with commitchange property. This is not working. When I assign default value through code that value will get assigned always.

Any assistance would be greatly appreciated

Best answer by npetrosov31

Thanks.I have set SyncPosition  as true and the Smart Panel’s AutoCallBack enabled. Below is the code that i am using for the popup panel.

  public PXAction<CWSyncInvoiceLine> ViewInvProdDetails;
  [PXButton(CommitChanges = true)]
  [PXUIField(DisplayName = "Import Product")]
  protected virtual IEnumerable viewInvProdDetails(PXAdapter adapter)
  {
      var row = CWSyncInvDetails.Current;

      if (row == null)
          return adapter.Get();     

 

      List<ProductCatalog> items = Service.GetProduct().Result;
      var item = items.Where(x => x.identifier == row?.ProductID).FirstOrDefault();
      ProductPanelView.Cache.Clear();

 

      if (item == null) return adapter.Get();
      var panel = new CWProductPanel
      {
          ProductID = item?.id,
          Identifier = item?.identifier,
          Description = item?.description,         
          ItemType = "NONSTOCK",//default
          Type = item.type?.name,
          ProductClass = item?.productClass,        

 

      };

 

      ProductPanelView.Insert(panel);

      if (ProductPanelView.AskExt() == WebDialogResult.OK)
      {         
          string type = ProductPanelView.Current?.ItemType;
          if (string.IsNullOrEmpty(type))
              throw new PXException(Messages.stockOrNonstock);

 

 

          if (type == "STOCK")
          {
              // Create item and return graph

 

              InventoryItemMaint itemGraph = CreateInventoryItem(ProductPanelView.Current);              

              // Redirect to the new item
              throw new PXRedirectRequiredException(itemGraph, "Stock Item")
              {
                  Mode = PXBaseRedirectException.WindowMode.NewWindow
              };
          }         

 

 

      }

      return adapter.Get();
  }

 

This looks like I was asking for. When you do the ask by this line:      

if (ProductPanelView.AskExt() == WebDialogResult.OK)

popup is coming up. Then you click Ok on the popup. What does happen on the code side at that point? It starts working from the beginning. That means it goes to 

ProductPanelView.Cache.Clear();

 

      if (item == null) return adapter.Get();
      var panel = new CWProductPanel
      {
          ProductID = item?.id,
          Identifier = item?.identifier,
          Description = item?.description,         
          ItemType = "NONSTOCK",//default
          Type = item.type?.name,
          ProductClass = item?.productClass,        

 

      };

      ProductPanelView.Insert(panel);
 

and all of your previous data is being removed on this point. I recommend you to check if there is already an answer to the ask and if there is no answer then do the clearing and creating.

if (ProductPanelView.View.Answer != WebDialogResult.OK)
      {     

      List<ProductCatalog> items = Service.GetProduct().Result;
      var item = items.Where(x => x.identifier == row?.ProductID).FirstOrDefault();
      ProductPanelView.Cache.Clear();

 

      if (item == null) return adapter.Get();
      var panel = new CWProductPanel
      {
          ProductID = item?.id,
          Identifier = item?.identifier,
          Description = item?.description,         
          ItemType = "NONSTOCK",//default
          Type = item.type?.name,
          ProductClass = item?.productClass,        

 

      };

 

      ProductPanelView.Insert(panel);

}

 

something like this should make it work

12 replies

Forum|alt.badge.img+8
  • Captain II
  • January 6, 2026

Are there other fields on your smart panel that are retaining their values?  Or is there only the one dropdown field?


Forum|alt.badge.img

Yes, there are other fields available in the grid; however, they are intended for display only. The dropdown field is the only enabled field.


Forum|alt.badge.img+8
  • Captain II
  • January 6, 2026

Does the unbound DAC have field that defines a unique key?


Forum|alt.badge.img

No, it has only a single record, so I am using a filter view.


Forum|alt.badge.img+8
  • Captain II
  • January 6, 2026

Can you show the code where you’re calling .Ask?


Forum|alt.badge.img

I am invoking the smart panel from a grid-level action button.


Forum|alt.badge.img+4

Hi ​@jayasebastian00 

Try to avoid using PXFilter for your grid. Instead, you can use SelectFrom or PXSelect, define the key field, and then implement a Data View Delegate in your BLC.

In the delegate, you can define and return a single record as needed.

Additionally, to avoid losing user-entered field values when using this approach, please refer to the following topic:

 


npetrosov31
Jr Varsity I
Forum|alt.badge.img+1
  • Jr Varsity I
  • January 6, 2026

Hi ​@jayasebastian00,

I will ask this as you did not post your code for action. Are you sure that you don’t clear cache before asking the popup? Whenever you click OK the code does not continue from the stopped point, it starts from the start. And if you clear the cache of the filter before “ask” the value will be lost.


Forum|alt.badge.img+2
  • Pro II
  • January 6, 2026

@jayasebastian00 

Since CommitChanges is already in place, this appears to be an ASPX-level Smart Panel or Grid configuration issue. Please review settings such as SyncPosition and the Smart Panel’s AutoCallBack behavior.

Sharing the relevant ASPX and DAC code snippets would help the community identify the root cause more easily.


Forum|alt.badge.img

Thanks.I have set SyncPosition  as true and the Smart Panel’s AutoCallBack enabled. Below is the code that i am using for the popup panel.

  public PXAction<CWSyncInvoiceLine> ViewInvProdDetails;
  [PXButton(CommitChanges = true)]
  [PXUIField(DisplayName = "Import Product")]
  protected virtual IEnumerable viewInvProdDetails(PXAdapter adapter)
  {
      var row = CWSyncInvDetails.Current;

      if (row == null)
          return adapter.Get();     

 

      List<ProductCatalog> items = Service.GetProduct().Result;
      var item = items.Where(x => x.identifier == row?.ProductID).FirstOrDefault();
      ProductPanelView.Cache.Clear();

 

      if (item == null) return adapter.Get();
      var panel = new CWProductPanel
      {
          ProductID = item?.id,
          Identifier = item?.identifier,
          Description = item?.description,         
          ItemType = "NONSTOCK",//default
          Type = item.type?.name,
          ProductClass = item?.productClass,        

 

      };

 

      ProductPanelView.Insert(panel);

      if (ProductPanelView.AskExt() == WebDialogResult.OK)
      {         
          string type = ProductPanelView.Current?.ItemType;
          if (string.IsNullOrEmpty(type))
              throw new PXException(Messages.stockOrNonstock);

 

 

          if (type == "STOCK")
          {
              // Create item and return graph

 

              InventoryItemMaint itemGraph = CreateInventoryItem(ProductPanelView.Current);              

              // Redirect to the new item
              throw new PXRedirectRequiredException(itemGraph, "Stock Item")
              {
                  Mode = PXBaseRedirectException.WindowMode.NewWindow
              };
          }         

 

 

      }

      return adapter.Get();
  }

 


npetrosov31
Jr Varsity I
Forum|alt.badge.img+1
  • Jr Varsity I
  • Answer
  • January 7, 2026

Thanks.I have set SyncPosition  as true and the Smart Panel’s AutoCallBack enabled. Below is the code that i am using for the popup panel.

  public PXAction<CWSyncInvoiceLine> ViewInvProdDetails;
  [PXButton(CommitChanges = true)]
  [PXUIField(DisplayName = "Import Product")]
  protected virtual IEnumerable viewInvProdDetails(PXAdapter adapter)
  {
      var row = CWSyncInvDetails.Current;

      if (row == null)
          return adapter.Get();     

 

      List<ProductCatalog> items = Service.GetProduct().Result;
      var item = items.Where(x => x.identifier == row?.ProductID).FirstOrDefault();
      ProductPanelView.Cache.Clear();

 

      if (item == null) return adapter.Get();
      var panel = new CWProductPanel
      {
          ProductID = item?.id,
          Identifier = item?.identifier,
          Description = item?.description,         
          ItemType = "NONSTOCK",//default
          Type = item.type?.name,
          ProductClass = item?.productClass,        

 

      };

 

      ProductPanelView.Insert(panel);

      if (ProductPanelView.AskExt() == WebDialogResult.OK)
      {         
          string type = ProductPanelView.Current?.ItemType;
          if (string.IsNullOrEmpty(type))
              throw new PXException(Messages.stockOrNonstock);

 

 

          if (type == "STOCK")
          {
              // Create item and return graph

 

              InventoryItemMaint itemGraph = CreateInventoryItem(ProductPanelView.Current);              

              // Redirect to the new item
              throw new PXRedirectRequiredException(itemGraph, "Stock Item")
              {
                  Mode = PXBaseRedirectException.WindowMode.NewWindow
              };
          }         

 

 

      }

      return adapter.Get();
  }

 

This looks like I was asking for. When you do the ask by this line:      

if (ProductPanelView.AskExt() == WebDialogResult.OK)

popup is coming up. Then you click Ok on the popup. What does happen on the code side at that point? It starts working from the beginning. That means it goes to 

ProductPanelView.Cache.Clear();

 

      if (item == null) return adapter.Get();
      var panel = new CWProductPanel
      {
          ProductID = item?.id,
          Identifier = item?.identifier,
          Description = item?.description,         
          ItemType = "NONSTOCK",//default
          Type = item.type?.name,
          ProductClass = item?.productClass,        

 

      };

      ProductPanelView.Insert(panel);
 

and all of your previous data is being removed on this point. I recommend you to check if there is already an answer to the ask and if there is no answer then do the clearing and creating.

if (ProductPanelView.View.Answer != WebDialogResult.OK)
      {     

      List<ProductCatalog> items = Service.GetProduct().Result;
      var item = items.Where(x => x.identifier == row?.ProductID).FirstOrDefault();
      ProductPanelView.Cache.Clear();

 

      if (item == null) return adapter.Get();
      var panel = new CWProductPanel
      {
          ProductID = item?.id,
          Identifier = item?.identifier,
          Description = item?.description,         
          ItemType = "NONSTOCK",//default
          Type = item.type?.name,
          ProductClass = item?.productClass,        

 

      };

 

      ProductPanelView.Insert(panel);

}

 

something like this should make it work


Forum|alt.badge.img

Thank you so much for your suggestion. It helped me fix the issue.