我有两张桌子:
Table: country1 - fields: CountryId ,CountryName
Table: City1 - fields: CityId, CityName, CountryId
CountryId
中的2个表之间存在关联,每个城市都有Country id
,并且有一个包含单个数据源的表单City1
和带有字段CityId,CityName, CountryId
的网格
我需要在网格中显示CountryName
而不是CountryId
我在design-designs-grid-methods-new
方法
display CountryName method1(City1 cit)
{
Country1 c1;
select CountryName from c1
where c1.CountryId == cit.CountryId;
return c1.CountryName;
}
但是当表单打开时,ID仍然显示为id而不是CountryName
答案 0 :(得分:1)
如果可能,请努力将display methods添加到其所属的表格中,在这种情况下City1
:
display CountryName contryName()
{
return (select firstOnly CountryName from Country1
where Country1.CountryId == this.CountryId).CountryName;
}
表上的显示方法不带参数,而是使用this
关键字
为了避免冗余变量,您可以使用内联select expression,如此处所示
将display方法从表拖到表单容器控件后,请记住在结果控件上设置Datasource
属性。
答案 1 :(得分:-1)
将显示方法移动到表单的dataSource。同时从网格中删除countryid字段并将显示方法拖动为网格字段。 推荐的方法是在表City1中添加显示方法。为此需要修改现有的显示方法以使用表缓冲区。