Is it possible to have a Graph and page utilize an completely unbound DAC?
When attempting this currently in 4.20 I\'m receiving the following error message:
<
To take control of the select process, you need to create a delegate that will be invoked when the UnboundInfo view is selected:
public IEnumerable unboundInfo()
{
//TODO: Put your logic to return a new instance of UnboundDAC here
}
Inside this delegate, you are free to use whatever mechanism you want to retrieve the record(s) that should be returned by this unbound select. For example, you can create one or more objects on the fly and return them:
public IEnumerable unboundInfo()
{
yield return new UnboundDAC() { UnboundKey = 1, UnboundText = "A" };
yield return new UnboundDAC() { UnboundKey = 2, UnboundText = "B" };
}
If you somehow need to allow the user to edit the values in your UnboundDAC, you could leverage the Cache, and insert the records in the cache the first time the view is selected:
public IEnumerable unboundInfo()
{
PXCache cache = _Graph.Caches[typeof(Table)];
cache._AllowInsert = true;
cache._AllowUpdate = true;
if(cache.Current == null)
{
cache.SetStatus(new UnboundDAC() { UnboundKey = 1, UnboundText = "A" }, PXEntryStatus.Held);
cache.SetStatus(new UnboundDAC() { UnboundKey = 2, UnboundText = "B" }, PXEntryStatus.Held);
}
return UnboundInfo.Cache.Cached;
}
Finally, you could take a look at the internal implementation of PXFilter; PXFilter is a specialized PXSelect that doesn't actually select anything from the database; all it does it insert one row in the cache the first time it is selected, and prevent persisting of this row. You could use a similar technique to create a PXUnboundSelect class that could be reused easily in multiple graphs.