Display Methods - Multiple Form Data Sources

微笑、不失礼 提交于 2019-12-22 08:27:02

问题


This may seem a simple question, but for some reason I am vexed.

I have a form with 3 datasources - InventTable, InventSum, InventDim.

So, for example, my grid shows;

Item, Name, Site, Warehouse, Physical Stock

I have placed a display method on InventDim form DataSource, but I need access to the ItemId from either inventTrans or InventSum. (Obviously looking for the "current" itemId).

All I can access is the inventDim which is passed as a parameter _inventDim, as standard.

What is the best way to access the "current" itemId?


回答1:


Okay, I found the answer, with great thanks to this reference by Joris de Gruyter;

http://daxmusings.blogspot.co.uk/2011/10/forum-advanced-display-method-querying.html

The key was to put the display method on the InventSum datasource.

You can then use _inventSum.joinChild() to retrieve the linked inventDim, here is Joris' example;

display Qty AvailPhysical(InventSum _inventSum)
{
    InventDim       joinDim, dimValues;
    InventDimParm   dimParm;
    InventSum       localSum;

    //THE IMPORTANT LINE...
    dimValues.data(_inventSum.joinChild());

    dimParm.initFromInventDim(dimValues);

    select sum(AvailPhysical) from localSum where localSum.ItemId == _inventSum.ItemId
        #InventDimExistsJoin(localSum.InventDimId, joinDim, dimValues, dimParm);

    return localSum.AvailPhysical;
}

I am sure this will help someone out in the future!



来源:https://stackoverflow.com/questions/11452892/display-methods-multiple-form-data-sources

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