Need help at: Lookup Advanced

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1160
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Need help at: Lookup Advanced

Post by onoehring » 2019-06-04 15:00

Hi,
I am trying to do something quite simple:
I want to show 2 columns in a dropdown.

As suggested here ( viewtopic.php?f=2&t=3015&p=9990&hilit=l ... nced#p9991 ) I have created an additional field in my AppGini "Table" named "Vorkommen". This field is integer and empty. The field has no meaning, but to be available in the drop down as second field.
The advanced SQL query is

Code: Select all

Select
    ecomo_Location.Bezeichnung,
    Count(ecomo_Container.ID_Location) As Vorkommen
From
    ecomo_Container Right Join
    ecomo_Location On ecomo_Container.ID_Location = ecomo_Location.ID_Location
Group By
    ecomo_Location.Bezeichnung
But in the generated application, nothing is shown :-(
Please see images for more context.

What do i need to change in AppGini to simply show the 1st dropdown "Bezeichnung" (i.e. 13-1-1) and in the second dropdown the count of that should be shown as calculated by the query column "Vorkommen" - for 13-1-1 there should be a 0.
ec1.png
ec1.png (36.69 KiB) Viewed 3236 times
ec2.png
ec2.png (56.82 KiB) Viewed 3236 times
Olaf

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1160
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Need help at: Lookup Advanced

Post by onoehring » 2019-06-04 15:10

Hi,

one problem seems solved: My query was definetly missing the primary key.
I added the ID_Location to the query and at least the first column (Bezeichnung) is shown right now.
Olaf

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1638
Joined: 2018-04-01 10:12

Re: Need help at: Lookup Advanced

Post by pbottcher » 2019-06-04 18:17

Hi, you can try

select id_location, Bezeichnung from (Select ecomo_Location.id_location, concat_ws(' ',ecomo_Location.Bezeichnung,count(ecomo_Container.ID_Location)) as Bezeichnung from ecomo_Container Right join ecomo_Location on ecomo_Location.ID_Location = ecomo_Container.ID_Location group by ecomo_Location.Bezeichnung) ecomo_Location

use only one field Bezeichnung
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1160
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Need help at: Lookup Advanced

Post by onoehring » 2019-06-05 06:14

Hi pbötcher,

thank you for that suggestion. I did it in a similar way, using "Beschreibung" only, but CONCAT directly:

Code: Select all

Select
    ecomo_Location.ID_Location,
    CONCAT (ecomo_Location.Bezeichnung, ' (',    Count(ecomo_Container.ID_Location), ')')
From
    ecomo_Container Right Join
    ecomo_Location On ecomo_Container.ID_Location = ecomo_Location.ID_Location
Group By
    ecomo_Location.ID_Location,
    ecomo_Location.Bezeichnung
Strange, that the other way did not work.

Olaf

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1638
Joined: 2018-04-01 10:12

Re: Need help at: Lookup Advanced

Post by pbottcher » 2019-06-05 06:33

Hi,
good to see that you got it working. Did you test that you can search also for the count(ecomo_Container.ID_Location) value?
If I remember correctly that was an issue. But may work now.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1160
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Need help at: Lookup Advanced

Post by onoehring » 2019-06-05 06:47

Hi pbötcher,

I am not sure what search you mean.
I posted an annoyance here ( viewtopic.php?f=11&t=3035 ) where it actually seems, that one can not search for something in an "advanced" lookup field.
Did you mean that?

Olaf

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1638
Joined: 2018-04-01 10:12

Re: Need help at: Lookup Advanced

Post by pbottcher » 2019-06-05 06:59

Hi,

in your example posted at the top. if you search for 0 would you see now the entry 13-1-1 (0) ?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1638
Joined: 2018-04-01 10:12

Re: Need help at: Lookup Advanced

Post by pbottcher » 2019-06-05 07:00

In the other post I would assume you have an sql error happening. If the select drop down does not come back, usually there is an sql happening behind the scene
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1160
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Need help at: Lookup Advanced

Post by onoehring » 2019-06-05 07:23

Hi,

no, that seems not to be the problem - as the SQL is run (and presented in the dropdown) correctly.
SQL is not

Code: Select all

Select
    ecomo_Location.ID_Location,
    CONCAT (ecomo_Location.Bezeichnung, ' (',    Count(ecomo_Container.ID_Location), ')')
From
    ecomo_Container Right Join
    ecomo_Location On ecomo_Container.ID_Location = ecomo_Location.ID_Location
Group By
    ecomo_Location.ID_Location,
    ecomo_Location.Bezeichnung
This shows up like you can see in the picture, but searching does not limit the results (as it should be I suppose) once they have all been displayed.
I posted a relevant screencast here (.asf file): https://dl.olaf-noehring.de/?t=8a940625 ... eed4b4951b

AppGini Screenshot
ec3.png
ec3.png (42.87 KiB) Viewed 3208 times
Olaf

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1638
Joined: 2018-04-01 10:12

Re: Need help at: Lookup Advanced

Post by pbottcher » 2019-06-05 07:32

Hi could you try my code I posted
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1160
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Need help at: Lookup Advanced

Post by onoehring » 2019-06-05 07:45

Hi,

I copied your code from above

Code: Select all

select id_location, Bezeichnung from (Select ecomo_Location.id_location, concat_ws(' ',ecomo_Location.Bezeichnung,count(ecomo_Container.ID_Location)) as Bezeichnung from ecomo_Container Right join ecomo_Location on ecomo_Location.ID_Location = ecomo_Container.ID_Location group by ecomo_Location.Bezeichnung) ecomo_Location 
It DOES work!
Great.
I then changed your code to add brackets around the count

Code: Select all

select id_location, Bezeichnung from (Select ecomo_Location.id_location, concat(ecomo_Location.Bezeichnung,' (',count(ecomo_Container.ID_Location),')') as Bezeichnung from ecomo_Container Right join ecomo_Location on ecomo_Location.ID_Location = ecomo_Container.ID_Location group by ecomo_Location.Bezeichnung) ecomo_Location 
and now this works as well.
ec5.png
ec5.png (5.67 KiB) Viewed 3203 times
Thank you for your time and knowledge.
Olaf

Post Reply