【问题标题】:Acumatica - get the last displayed recordAcumatica - 获取最后显示的记录
【发布时间】:2018-06-03 08:44:30
【问题描述】:

是否有一种雄辩的方式,或多或少,可以在 Acumatica 的网格中获取最后显示的记录?假设即使他们完成了所有的排序和重新排列,有没有办法例如按下网格上的按钮来获取最后一条记录?基本上,我想将该记录复制为新记录。

【问题讨论】:

    标签: acumatica


    【解决方案1】:

    为您的按钮创建一个 PXAction。 在 PXAction 内部,在您的数据视图中迭代直到最后一条记录。 例如,如果绑定到网格的数据视图的名称是 YzLines,并且网格线 (DAC) 中的对象类型是 Yz,那么它可以是:

    Yz lastLine;
    foreach (Yz line in YzLines.Select()) 
       lastLine = line;
    

    要获取最后一条记录,您还可以使用 .Last() 或 .LastOrDefault()。

    如果你需要根据客户端排序的最后一条记录,你应该实现一个数据视图委托,它看起来像这样:

    protected virtual IEnumerable yzLines()
    {
        PXSelectBase<Yz> cmd =
            new PXSelectJoinGroupBy<Yz, ...>(this);
    
        int startRow = PXView.StartRow; //Get starting row of the current page
        int totalRows = 0;
    
        foreach (PXResult<Yz> res in
                                cmd.View.Select(null, null,
                                PXView.Searches,
                                ARDocumentList.View.GetExternalSorts(),//Get sorting fields
                                ARDocumentList.View.GetExternalDescendings(),//Get sorting direction
                                ARDocumentList.View.GetExternalFilters(),//Get filters
                                ref startRow,
                                PXView.MaximumRows, //Get count of records in the page
                                ref totalRows))
        {
            //processing of records
        }
    
        PXView.StartRow = 0;//Reset starting row
    }
    

    【讨论】:

    • 这会让最后一条记录显示在网格中吗?我认为 OP 想要考虑到排序和分页的最后一条记录。类似于视图委托的东西:Select(PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startrow, PXView.MaximumRows, ref totalrow)
    • 否则,YzLines.Select().LastOrDefault() 会这样做。
    • Ilya,您发布的示例不起作用。它没有考虑他们是否对列进行排序或移动它们。 @HB_ACUMATICA 在某处有 PXView 的例子吗?对于这种情况,您会碰巧拥有它吗?
    • Stan,如果您需要考虑客户端排序,您应该编写一个数据视图委托(我已将代码示例发布到原始答案中)。有关数据视图代表的详细信息,请参阅 T200 课程和 help.acumatica.com。
    • 谢谢,伊利亚。我今天晚些时候会试试这个。如果您想避免复制原始 BQL,以下内容也有帮助:asiablog.acumatica.com/2016/06/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-06
    • 2013-12-17
    相关资源
    最近更新 更多