Iniciar uma conversa

Ajax with select fields type (one field refreshing other)

In this topic we will use our Ajax, with two fields type select,(combobox).

One field will list categories of the products and the others the product it self.

 

Table Categories

 

Id
Categories
1
Condiments
2
Seafood
3
Grains/Cereals
4
Beverages

Table Products

 

Id CategoryId
Product
1 1
Outback Lager
2 2
Boston Crab Meat

In an form, we will use Ajax to perform that task, first we need to enable Ajax in the application, the menu Configuration->Ajax Use = yes. Click in the field categories and change the data type to select(combobox), go to section Edition Lookup and change the lookup method to Automatic with this SQL:

Fields of the Categories

select Id, Categories from categories

This SQL statement will show the name of the categorie and will sabe the id.

In the field product, change the data type to select(combobox), go to section Edition Lookup and change the lookup method to Automatic with this SQL:

select product from products where CategoryId = "{categorie}"

{categorie} -> is the field that will show the select field(combobox) with the result of the SQL: select Id, Categories from categories.

After this, click on the field categories, go to the section Ajax Processing and check the option "Use AJAX to reload other fields of type Select, Double select, Radio and Checkbox. " ... them doubleclick on the field product to check it to reload.

 

After this, execute the application.

Escolher arquivos ou arraste e solte arquivos
Esse artigo foi útil?
Sim
Não
  1. Amanda Santos (Migrated deleted Agent)

  2. Publicado
  3. Atualizado

Comentários

  1. Ronyan Alves

    Equipe –

    You need to do the same process on the other fields. Please see the video below ( it's explain the process on run time ): https://youtu.be/aDeUvgqksh0 For the second question: On the select field configuration, on the category "Lookup Settings" have a option "Use title", put to Yes, write a title on "Title" iten, and put a internal value ( leave blank to null ) .
  2. Ronyan Alves

    Equipe –

    Please see the video below ( it's explain the process on run time ): https://youtu.be/aDeUvgqksh0
  3. gamo nana

    it does not work in my case. the variable {categorie} remains an integer meanwhile I set the key field as Id. please help me
  4. PT Viardi Bintang Terang

    How do you solve if there are multiple layer select field. Example : State -> Province -> District -> SubDistrict State refresh Province, District, SubDistrict Province refresh District, SubDistrict District refresh SubDistrict And since the method using 'onchange', how to set null / empty on the 1st value of the select box ?