1
votes

I have 2 tables:

Table: country1 - fields: CountryId ,CountryName 
Table: City1    - fields: CityId, CityName, CountryId

There is a relation between 2 tables through the CountryId, each city has a Country id and there is a form with single datasource City1 and grid with fields CityId,CityName, CountryId I need to display a CountryName instead of CountryId in the grid
I created a new method in design-designs-grid-methods-new methods

display CountryName method1(City1 cit)
{
    Country1 c1;
    select CountryName from c1
        where c1.CountryId == cit.CountryId;
    return c1.CountryName;
}

but when form open the id still shows as a id not a CountryName

2

2 Answers

1
votes

If possible, strive to add display methods to the table where it belongs, in this case City1:

display CountryName contryName()
{
    return (select firstOnly CountryName from Country1 
                where Country1.CountryId == this.CountryId).CountryName;
}

Display methods on tables takes no arguments, use this keyword instead.
To avoid redundant variables you may use an inline select expression as show here.
After dragging the display method from the table to the form container control, remember to set the Datasource attribute on the resulting control.

-1
votes

Move your display method to dataSource of the form. Also remove countryid field from grid and drag display method as grid field. Recommended approach is adding the display method in table City1. For that need to modify your existing display method to use table buffer as this.