按项目名称过滤 - 库存管理/查询/现有

时间:2016-01-22 13:09:12

标签: axapta microsoft-dynamics dynamics-ax-2012 dynamics-ax-2012-r3

据我所知,ProductName列是通过显示方法显示的。至少对于我在这里的实现,这个方法驻留在InventSum表中:

display public ItemNameDisplay itemName()
{
    // Fields might not have been selected on the specified buffers, or might have been updated since selection
    this.checkInvalidFieldAccess(false);

    if (this.InventDimId)
    {
        return this.inventTable().itemName(InventDim::find(this.InventDimId));
    }
    return this.inventTable().itemName();
}

当我按下Ctrl + G并尝试过滤数据时,对上面的列禁用此选项,我认为这是由于该显示方法而发生的。有什么方法可以实现这个功能吗?

我是否应该尝试(右键单击)在那里添加另一个MenuItem并在新对话框的帮助下进行过滤(我将在其中写下项目名称),然后以某种方式刷新表单?

更新1:

我已根据我的特殊情况找到并编辑了这种方法:

public void context()
{
   InventTable inventTable;

   int selectedMenu;
   real test;
   formrun fr;
   Args ag;
   Itemname strtext;
   querybuilddataSource qb1;
   queryrun qr;
   query q;
   PopupMenu menu = new PopupMenu(element.hWnd());
   int a = menu.insertItem('Find');
   int c = menu.insertItem('Remove Filter');


   selectedMenu = menu.draw();

   switch (selectedMenu)
   {
       case -1:
       break;

       case a:
       ag = new args('SysformSearch');
       fr = new formrun(ag);
       fr.run();
       fr.wait();
       strtext = fr.design().controlName('FindEdit').valueStr();

      if(strtext)
      {
          select ItemId from inventTable
          where inventTable.NameAlias == strtext;

          InventSum_DS.filter(FieldNum(InventSum,ItemId),Sysquery::value(inventTable.ItemId));
      }
      break;

      case c :
          InventSum_DS.removeFilter();
      break;

      Default:
      break;
   }
}

我认为这不是显示新PopupMenu的正确方法。我想挂钩通常的菜单,并在那里添加新的查找和删除筛选器。并且..删除过滤器需要一段时间,我应该以某种方式发出信号,以便用户不要惊慌。

2 个答案:

答案 0 :(得分:1)

使用上下文菜单不是这样做的方法,但是对这个想法是补充。

您需要做什么使用所需字段的数据源扩展表单。 在这种情况下,需要InventTable内部加入InventSumEcoResProduct内部加入InventTableEcoresProductTranslation内部加入EcoResProduct。将字段EcoresProductTranslation.Name添加为网格中的字段。

您必须使用首选语言进行范围调整。如果不存在该语言的翻译,则不会输出。

由于查询是按查询分组,因此您需要在EcoresProductTranslation.Name上进行分组。 表单的代码相当复杂,因此使其工作可能会很痛苦。

答案 1 :(得分:1)

我发现了这篇文章:

Join ItemName from (EcoResProductTranslation )

基本上,我们创建一个基于InventTable,EcoResProduct和EcoResProductTranslation的查询,以便从InventTable的Product字段开始获取产品名称。

在InventSum上添加了一个新关系:

enter image description here

关于InventOnHandItem> DataSources> InventSum>方法> executeQuery我添加了新的ds:

FormDataSource _inventLookup = null 

在课堂上:

InventDimCtrl_Frm_OnHand> modifyQuery,我添加了这个参数:

public void modifyQuery(
   FormDataSource _inventSum_DS,
   FormDataSource _inventDim_DS,
   FormDataSource _inventLookup = null
)

所以现在我有了这个:

QueryBuildDataSource    qbsInventLookup;

查询构建数据源实例:

if(_inventLookup)
{
    qbsInventLookup = query.dataSourceName(_inventLookup.name());

    //filter current company language
    //qbr = SysQuery::findOrCreateRange(qbsInventLookup, fieldnum(InventLookupView, LanguageId));
    //qbr.value(queryValue(CompanyInfo::languageId()));

    qbsInventLookup.addGroupByField(fieldNum(InventLookupView, Name));
    //qbsInventLookup.addGroupByField(fieldNum(InventLookupView,NameAlias));
}

这部分代码:

An existing connection was forcibly closed by the remote host

新创建的视图将作为数据源添加到InventSum中:

enter image description here

将“名称”字段从此数据源拖到网格中。它对我来说很好。

相关问题