How to make DataSourceCriteria dependent to a property in XAF?

vaheeds picture vaheeds · Mar 10, 2012 · Viewed 7.5k times · Source

I use the eXpressApp Framework to develop a windows application. I want to filter a lookup view property editor depending on an enum property in my class.

this is my code:

Category Class:

    private TranType tranType;
    public TranType TranType
    {
        get
        {
            return tranType;
        }
        set
        {
            SetPropertyValue("TranType", ref tranType, value);
        }
    }

    private string categoryName;
    public string CategoryName
    {
        get
        {
            return categoryName;
        }
        set
        {
            SetPropertyValue("CategoryName", ref categoryName, value);
        }
    }

    private Category parentCategory;
    public Category ParentCategory
    {
        get
        {
            return parentCategory;
        }
        set
        {
            SetPropertyValue("ParentCategory", ref parentCategory, value);
        }
    }

Tran Class:

    private Category category;
    [DataSourceCriteria("TranType == TranType")]
    public Category Category
    {
        get
        {
            return category;
        }
        set
        {
            SetPropertyValue("Category", ref category, value);
        }
    }

    private static TranType myTranType;
    [ImmediatePostData]
    public TranType MyTranType
    {
        get
        {
            return myTranType;
        }
        set
        {
            SetPropertyValue("MyTranType", ref myTranType, value);
        }
    }

Each Category has a TranType and I want when the user chooses for example TranType=Expense, the categories filtered in the lookup based on their given TranType.

Thank You for help.

Answer

Marty picture Marty · Mar 13, 2012

If What You wanna do is filter the available categories in a lookup in a view of a Tran class, then just put it this way

private Category category;
[DataSourceCriteria("MyTranType")]
public Category Category
{
    get
    {
        return category;
    }
    set
    {
        SetPropertyValue("Category", ref category, value);


     }
}
private static TranType myTranType;
[ImmediatePostData]
public TranType MyTranType
{
   get
   {...

Take a look at this document http://documentation.devexpress.com/#Xaf/CustomDocument2681