Rick
Rick

Reputation: 1311

How to retrieve the filtered records

Say my Transactions view has five lines.

enter image description here

If I set a filter on Quantity to show only those less than 10

enter image description here

I'll end up with this :

enter image description here

My question is how do I access these two records as what's shown in the grid ? Transactions.Select() gives me all/unfiltered five rows. I've implemented the view delegate and can see the filtered rows from there. But are they stored somewhere else as a cached object or something ?

TIA

Upvotes: 0

Views: 442

Answers (2)

Viktor
Viktor

Reputation: 66

The filters stored in an PXView object that can be accessed through a View property of your select. You can use Select method with multiple parameters to retrieve filtered records:

var startRow = PXView.StartRow;
int totalRows = 0;
var list = Transactions.View.Select(PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters,
                ref startRow, PXView.MaximumRows, ref totalRows);

Upvotes: 0

Joshua Van Hoesen
Joshua Van Hoesen

Reputation: 1732

The example below creates a button on AR Document Release that marks all records as selected includes filtering that has been defined :

public PXAction<BalancedARDocument> SelectAll;

    [PXButton]
    [PXUIField(DisplayName = "Select All")]
    protected virtual void selectAll()
    {
        int min = 0;
        int totalRows = 0;

        foreach (PXResult<BalancedARDocument, ARDocumentRelease.ARInvoice, ARDocumentRelease.ARPayment, Customer, ARAdjust> doc in Base.ARDocumentList.View.Select(null, null, PXView.Searches, Base.ARDocumentList.View.GetExternalSorts(), Base.ARDocumentList.View.GetExternalDescendings(), Base.ARDocumentList.View.GetExternalFilters() ?? new PXFilterRow[0], ref min, 0, ref totalRows))
        {
            (doc[typeof(BalancedARDocument)] as BalancedARDocument).Selected = true;
            Base.ARDocumentList.Update(doc);
        }
    }

Upvotes: 2

Related Questions