Johan W.
Johan W.

Reputation: 127

Bind boolean to a label based on user's selection

I am designing a page in which informs a manager whether an applicant requires a work permit. For this I have created a data table called "Countries" that contains a string field "countries" and a boolean "EU_member". If the country is a member of the European Union the boolean is true and vice-versa.

I have set up a dropdown field in the page from which the manager can select the country. I now want to bind a label to the boolean field, so that it shows whether the country is part of the European Union or not. Right now, it is only bound to the country field.

@datasources.Countries.query.filters.country._equals=Dropdown1.value;

My second idea was to include a server script that is triggered by the onValueEdit method of the dropdown field

function checkWorkPermit(widgetValue) {
  var query = app.models.Countries.newQuery();
  query.filters.country._equals = widgetValue;
  var records = query.run();
  return records[0].EU_Member;
}

but the console returns

checkWorkPermit is not defined at ....Panel8.Dropdown1.onValueEdit:1:1

Upvotes: 0

Views: 132

Answers (1)

Pavel Shkleinik
Pavel Shkleinik

Reputation: 6347

Considering, that the dropdown's options property is bound to smth like this:

@datasources.Countries.items

binding for the label could look similar to this:

@pages.MyPage.descendants.CountriesDropDown.value.EU_member ?
    'Work permit is required' :
    'Work permit is NOT required'

Upvotes: 1

Related Questions