Axapta:查找字段显示的是字符串值而不是ID? [英] Axapta: Lookup field display the string value instead of the ID?

查看:50
本文介绍了Axapta:查找字段显示的是字符串值而不是ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当AX生成表单和网格时,将正确填充所有查找,但是查找项的ID将显示在表单中.查看有意义的值的唯一方法是单击该字段,这并不是很理想.有没有一种方法可以在表格中显示查找值而不是其后面的ID号?

When AX generates forms and grids, all the lookups are populated properly, but the ID of the lookup item is displayed in the form. The only way to see values that make sense is to click on the field--not really ideal. Is there a way to display the lookup value in the form instead of the id number behind it?

我希望"tableB"表单显示tableA_value而不是tableA_id.

I would like the "tableB" form to display the tableA_value instead of the tableA_id.

tableA

  • tableA_id(int-唯一)
  • tableA_value(字符串-非唯一)

tableB

  • tableB_id(int-唯一)
  • tableA_id(int-与tableA的关系)
  • tableB_datafields(misc)

谢谢

推荐答案

无法找到更改查找本身值的方法,因此我在其旁边放置了一个静态字段,该字段在更改查找时会随时更新.这是我最终完成的方式:

Couldn't find a way to change the value of the lookup itself, so I put a static field next to it that updates any time the lookup is changed. Here's how I ended up doing it:

表A上的显示方法:

display [datatype] lookupName(tableA _tableA)
{
    ;
    return tableB::find(_tableA.[tableA id column]).[tableB string column];
}

在表B上查找方法:

static tableB find([datatype] [lookup variable], boolean _forUpdate = false,
 ConcurrencyModel _concurrencyModel = ConcurrencyModel::Auto)
{
[TableB] [tableB];

if ([lookup variable])
{
    if (_forUpdate)
    {
        tableB.selectForUpdate(_forUpdate);
        if (_concurrencyModel != ConcurrencyModel::Auto)
        {
            tableB.concurrencyModel(_concurrencyModel);
        }
    }

    select firstonly tableB
        where tableB.[lookup column] == [lookup variable];
}
return tableB;

}

将表A和B添加为表单的数据源.

Added both table A and B as datasources for the form.

在表单中添加了一个字符串字段.

Added a string field to the form.

将表A设置为字段的数据源,并将lookupName设置为DataMethod.

Set table A as the DataSource for the field and lookupName as the DataMethod.

在查找字段中添加了修改后的方法,以使静态字段更新:

Added a modified method to the lookup field to cause the static field to update:

element.redraw();

希望这对某人有帮助.

这篇关于Axapta:查找字段显示的是字符串值而不是ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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