Customization of a Data View
Suppose that you have declared the Objects data view within the base BLC, as shown below.
public class BaseBLC : PXGraph<BaseBLC, DAC>
{
public PXSelect<DAC> Objects;
}
You can alter a data view within a BLC extension in the following ways:
- By altering the data view within a BLC extension. A data view that is redeclared within a BLC
extension replaces the base data view in the Views collection of the BLC
instance. Consider the following example of a first-level BLC
extension.
public class BaseBLCExt : PXGraphExtension<BaseBLC> { public PXSelectOrderBy<DAC, OrderBy<Asc<DAC.field>>> Objects; }
The Views collection of a BLC instance contains the PXView object, which uses the Objects data view declared within the first-level extension, instead of the data view declared within the base BLC.
Note:A data view redeclared within a BLC extension completely replaces the base data view within the Views collection of a BLC instance, including all attributes attached to the data view declared within the base BLC. You can either attach the same set of attributes to the data view or completely redeclare the attributes. - By declaring or altering the data view delegate in a BLC extension. The new delegate is
attached to the corresponding data view. Consider the following example of a
second-level BLC
extension.
public class BaseBLCExtOnExt : PXGraphExtension<BaseBLCExt, BaseBLC> { protected IEnumerable objects() { return PXSelect<DAC>.Select(Base); } }
The Views collection of a BLC instance contains the PXView object, which uses the Objects data view declared within the first-level extension, with the objects() delegate declared within the second-level extension (see the screenshot below).
To query a data view declared within the base BLC or a lower-level extension from the data view delegate, you should redeclare the data view within a BLC extension. You do not need to redeclare a data member when it is not meant to be used from the data view delegate. Consider the following example of a second-level BLC extension.public class BaseBLCExtOnExt : PXGraphExtension<BaseBLCExt, BaseBLC> { protected IEnumerable objects() { return Base.Objects.Select(); } }
The new delegate queries the data view declared within the base BLC. Having redeclared the data view within the first-level extension, you prevent the data view execution from an infinite loop (see the following screenshot).
Note:If a data view declared within the base BLC contains a delegate, this delegate also gets invoked when the data view is queried from the new delegate (see the following figure).