How to retrieve the filtered records

柔情痞子 提交于 2021-01-29 20:09:06

问题


Say my Transactions view has five lines.

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

I'll end up with this :

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


回答1:


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);
        }
    }



回答2:


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);


来源:https://stackoverflow.com/questions/52870442/how-to-retrieve-the-filtered-records

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!