Skip to main content
Answer

Unbound DAC Documentation

  • December 3, 2024
  • 9 replies
  • 252 views

Forum|alt.badge.img

Hello, I need to present data received from a REST call from an external source. Most probably using PXGrid. 

My understanding is that I need an unbound DAC class to provide the data to the grid.

But I can’t find any documentation how to define the unbound DAC class and how to fill it with the data.

Thank you for any hint.

Best answer by darylbowman

You define a virtual DAC the same as you would any other DAC - just a public class derived from PXBqlTable and with IBqlTable interface.

The main difference is that your Data View should use PXFilter instead of PXSelect. This prevents the view from trying to select data from the database.

You can define a Data View Delegate which returns an IEnumerable in which you can create and populate the records in a List<> and return them at the end.

9 replies

darylbowman
Captain II
Forum|alt.badge.img+15
  • Answer
  • December 3, 2024

You define a virtual DAC the same as you would any other DAC - just a public class derived from PXBqlTable and with IBqlTable interface.

The main difference is that your Data View should use PXFilter instead of PXSelect. This prevents the view from trying to select data from the database.

You can define a Data View Delegate which returns an IEnumerable in which you can create and populate the records in a List<> and return them at the end.


Forum|alt.badge.img
  • Author
  • Freshman I
  • December 12, 2024

@darylbowman

Thank you for your response and sorry for being late testing it - I had some other issues in the meantime.

I tried to follow your instructions but the delegate function is not getting called. Am I doing something wrong? Are there some other conditions needed to make it working? 

 

    public PXFilter<SearchQuoteResultDAC> SearchQuoteResultsView;

 

    protected virtual IEnumerable searchQuoteResultsView()

    {

      // Implement the dynamic query

      List<SearchQuoteResultDAC> res = new List<SearchQuoteResultDAC>();

     ...

      return res;

    }

 

    public class SearchQuoteResultDAC : PXBqlTable, IBqlTable

    {

      #region Name

      [PXString]

      [PXUIField]

      public virtual String Name { get; set; }

      public abstract class name : PX.Data.BQL.BqlString.Field<name> { }

      #endregion

      #region ID

      [PXString]

      [PXUIField]

      public virtual String Id { get; set; }

      public abstract class id : PX.Data.BQL.BqlString.Field<id> { }

      #endregion

      #region Number

      [PXString]

      [PXUIField]

      public virtual String Number { get; set; }

      public abstract class number : PX.Data.BQL.BqlString.Field<number> { }

      #endregion

    }

 

<px:PXGrid runat="server" ID="CstPXGrid23" SkinID="Details" Width="100%" Height="100%" DataSourceID="ds">

      <Levels>

        <px:PXGridLevel DataMember="SearchQuoteResultsView">

          <Columns>

            <px:PXGridColumn DataField="Name" />

            <px:PXGridColumn DataField="Id" />

            <px:PXGridColumn DataField="Number" />

          </Columns>

        </px:PXGridLevel>

      </Levels>

      <AutoSize MinWidth="300" MinHeight="200" Enabled="True" />

</px:PXGrid>


darylbowman
Captain II
Forum|alt.badge.img+15
  • December 12, 2024

I believe the method needs to be public.


Forum|alt.badge.img
  • Author
  • Freshman I
  • December 12, 2024

Making the method public didn’t help.

I am still a beginner in Acumatica so there might be some stupid bug in my code.


darylbowman
Captain II
Forum|alt.badge.img+15
  • December 12, 2024

I don’t see anything glaringly wrong with the code you posted. Were you debugging or how can you tell it’s not hitting your delegate? An easy way to tell is to throw a PXException in the delegate and see if the screen loads.


Forum|alt.badge.img
  • Author
  • Freshman I
  • December 12, 2024

I’m debugging it, the breakpoint isn’t hit.


darylbowman
Captain II
Forum|alt.badge.img+15
  • December 12, 2024

You can check this out. It looks like you can also use a regular data view if you do it right.


Forum|alt.badge.img
  • Author
  • Freshman I
  • December 13, 2024

So far I was testing it in a dialog popup.

Today I tried it in a simple form and voilà! it is working there.

So now I just need to find out how to make it working in my dialog popup. Maybe the datasource not set correctly or something like that.


darylbowman
Captain II
Forum|alt.badge.img+15
  • December 13, 2024

I don’t know if this will help you or not. This is a more advanced way to open a dialog, which includes clearing and populating the data view. You may be able to tweak it to fit your scenario:

if (EscalationDialog.AskExt(
(graph, view) =>
{
EscalationDialog.Cache.ClearQueryCache();
EscalationDialog.View.Clear();
EscalationDialog.Cache.Clear();
EscalationDialog.Current = new ISEscalationActivity()
{
WorkgroupID = depotWorkgroup?.WorkGroupID
};
}, true) != WebDialogResult.OK)
return adapter.Get();