如何调用数据视图委托的基本方法 [英] How to invoke the base method of a dataview delegate

查看:20
本文介绍了如何调用数据视图委托的基本方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有数据视图委托的 PXGraph,我想覆盖它,以便我可以向网格上显示的数据添加更多自定义过滤器.

I have a PXGraph with a data view delegate I want to override so I can add a a few more custom filters to the datas displayed on the grid.

我知道如何覆盖和完全替换基本委托,但我不知道如何先执行数据视图的基本逻辑,然后将过滤器添加到结果中.

I know how I can override and totaly replace the base delegate, but I dont know how I can execute the base logic of the dataview first, then add my filter to the result.

所以我想要达到的结果是:

So the result I want to achieve is :

    [PXOverride]
public virtual IEnumerable details()
{
   var records = Base.details();
   return records.Where(...);
}

我尝试只复制整个原始数据视图委托,但它调用了基础图的许多私有成员,因此我也必须复制所有这些成员,这会导致代码中出现大量丑陋的重复.

I tried just copying the whole original dataview delegate but it calls a lot of privates members of the base graph so i'd have to copy all these members as well and it leads to a lot of ugly duplication in the code.

我的问题主要是我不能调用 Base.details() 因为细节数据视图委托被声明为受保护.

Edit : my problem is mainly that I can't call Base.details() because the details dataview delegate is declared as protected.

推荐答案

您走对了.剩下的唯一事情就是将 IEnumerable 集合转换为列表.您需要这样做,因为 Linq Where 方法不对 IEnumerable 集合进行操作.

You were on the right track. The only thing left is to convert the IEnumerable collection to a List. You need to do this because Linq Where method doesn't operate on IEnumerable collection.

以下是调用客户付款方法屏幕基本详细信息委托并使用 Linq 过滤结果的示例:

Here is an example calling Customer Payment Methods screen base details delegate and filtering the results using Linq:

using PX.Data;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace PX.Objects.AR
{
    public class CustomerPaymentMethodMaint_Extension : PXGraphExtension<CustomerPaymentMethodMaint>
    {
        public virtual IEnumerable details()
        {
            List<CustomerPaymentMethodDetail> records = Base.details().RowCast<CustomerPaymentMethodDetail>().ToList();

            return records.Where(record => record.Value == "Bob");
        }
    }
}

没有额外委托过滤器的结果:

Results without the additional delegate filter:

附加委托过滤器的结果:

Results with the additional delegate filter:

这篇关于如何调用数据视图委托的基本方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆