0

Dynamic combobox/dropdown list

Sorry in advance if this has been solved before.

I'm trying to create a table with a couple dynamic comboboxes. If option 1 is selected for combobox 1, then only options 1 to 6 will be available in combobox 2. If option 2 is selected for combobox 1, then only options 7 to 12 will be available in combobox 2. 

So far I've been trying to use tables with the options that populate each combobox. The comboboxes themselves are just relationships to those tables. I was hoping that using constrains would work to filter out the unwanted options, but that's where I'm stuck. 

Am I going in the right direction, or is there a better way to do this?

18 replies

null
    • Fred
    • 1 yr ago
    • Reported - view

    You use dynamic comboboxes and constraints. In Ninox contraints usually refers to reference fields. Dynamic choice fields do not use constraints per se. So this solution is using dynamic choice fields.

    I've included two ways of doing the selection. The first one (selection2) uses the relationship between the two tables. The second one (selection2a) is probably what most people will do.

      • Kruna
      • 1 yr ago
      • Reported - view

      what would be the solution, if I use multiple dynamic choice field? thank you, Kruna

    • Alex_Mumm
    • 1 yr ago
    • Reported - view

    Thanks Fred! That's exactly what I was looking for. 

    • Fred
    • 1 yr ago
    • Reported - view
      • Kruna
      • 1 yr ago
      • Reported - view

      wow!! thank you also for the explanation, because dumb as I am it makes it clearer to me also to understand the script.😆

      That works great👍

      I have still one question issue facing hereby. Pls taka a look at the sample db. I imported the data from my existing db. Is there a way to get the choices sort by 1.group and then by 2.abc? To explain better I colored the categories/subcategories. As you can see the group 'green' is in the middle and at the end and not grouped and sorted.

      I tried with order by and sort, but somehow it doesnt work.

      Do you have an idea, if its possibel at first place?

      Thanks, Kruna

      • Fred
      • 1 yr ago
      • Reported - view

      Are you talking about sorting the table view or sorting the choices in a dynamic choice field?

      • Kruna
      • 1 yr ago
      • Reported - view

      I am not sure if I am able to explain better, so here is a screenshot hoping to explain more clear, what i would like to achieve.

      The last field is a fx field (formula is Subcategory)

    • Fred
    • 1 yr ago
    • Reported - view
     said:
    Is there a way to get the choices sort by 1.group and then by 2.abc?

    Ninox can not do a multilevel sort with code commands. You have to create another field that combines the two fields you want to sort by and then sort by that field.

    In the Subcategory table, create a new formula field, I called it Sortfield. Then add this to the formula:

    Category.Category + "," + Subcategory
    

    You can test it out and add it to the table view of Subcategory and you can see how it works.

    Now you can go the Category tab of the Dashboard table and modify the Subcategory dynamic multi choice field to:

    let t := this;
    (select Subcategory)[contains(numbers(t.Category), number(Category))] order by Sortfield
    

    I hope it now shows how you want it.

      • Kruna
      • 1 yr ago
      • Reported - view

      yessss, that's exactly what I wanted to achieve, but (pls apologize) when it comes to print layout the fx field (formula Subcategory) shows not text but

      when I enter  the formula text(Subcategory) it shows the text, but not sorted like abc

      • Fred
      • 1 yr ago
      • Reported - view

      I don't do any printing, so I can't help you out there. Printing, in my opinion, is still a weak point of Ninox.

      • Kruna
      • 1 yr ago
      • Reported - view

      Fredoh ok, it doesnt matter, I may open a new post concerning printing, altough I think it could be a bug. YES you are absolutely right, the print engine is disaster, but still I can use it for my 'little' needs for now.

      Anyway I am more than happy that at least it is sorted by group and not mixed up. That its not sorted by abc, well I can live with that, even if there's no solution for it.

      So I really thank you very much for your help!👍🙂

      • Alain_Fontaine
      • 1 yr ago
      • Reported - view

      Another possibility:

      let t := this;
      ((select Subcategory)[contains(numbers(t.Category), number(Category))] order by Subcategory) order by Category.Category
      
      

      The trick is to order by the least significant field first. As far as I know, there is unfortunately no equivalent trick to sort table views, so a combined sort field must be created.

      • Kruna
      • 1 yr ago
      • Reported - view

      thank you very much for your help, but somehow didnt work either.

      I had the print issue also discussed in german forum and here is the solution - in formula field:

      let UKatRes := numbers(Subcategory);
      let sortUKat := ((select Subcategory) order by Category.Category + Subcategory);
      let result := for i in sortUKat do
              for j in UKatRes do
                  if i = record(Subcategory,j) then
                      i.Subcategory
                  end
              end
          end;
      join(result[!= ""], ", ")

      Now, its sorted by group and alphabatic order, which is also shown correctly in print layout. :-)

      Kruna

      • Alain_Fontaine
      • 1 yr ago
      • Reported - view

       I have zero experience with printing, but I understand that the function is severely rotten. So one should not try to print a DMC field, even if it has been correctly sorted, as shown on the screen. One thus need to produce a text field.

      One should not sort on two text fields by simply concatenating them. While it will work most of the time, it will fail for certain combinations of values. If one value of the most significant field is a subset of another value, incorrect orders will result.

      The proposed formula, with its two loops, seems a bit too complicated. May I propose instead:

      let UKatRes := numbers(Subcategory);
      let result := (((select Subcategory where contains(UKatRes, number(Id))) order by Subcategory) order by Category.Category).Subcategory;
      join(result[!= ""], ", ")
      

       

      • Kruna
      • 1 yr ago
      • Reported - view

      well compared to you guys, I have no experience with anything in Ninox :-), so I am glad for every help and support I get and thank you for that, very much appreciated.

      I tried your script and it works here as well.

      The solutions here are not taht crucial, but as it is part of a contract, which I need in printed form, I would like to have 'perfectly' for better reading. If all the subcategories are mixed up, it may disturb the reading, but thats my personal perception.

      have a nice day

      Kruna

      • Rafael Sanchis
      • Rafael_Sanchis
      • 1 yr ago
      • Reported - view

      Hi Kruna .

      You have the definitive example ? 

      • Kruna
      • 1 yr ago
      • Reported - view

      hi Rafael,

      here is th esample db.

      In table Dashboard - tab Category is the final example.

      You will find two formula fields the first ist just related to the dmcf Subactegory. It is colored and you could also add some icons. Thats just for me to have a better oberview

      In the second formula field is the actual script (from Alain) needed for printing. In printlayout  there is a 'test' layout.

      Saludos Kruna

    • Rafael Sanchis
    • Rafael_Sanchis
    • 1 yr ago
    • Reported - view

    I'm doing a WBS (Work Breakdown Structure) on Multiple Choice Dynamic for each Level 

Content aside

  • 1 yr agoLast active
  • 18Replies
  • 532Views
  • 6 Following