dropdown values are not sorted when element is a list of multiple quoted numbers

Discussion in 'Professional Support' started by rpc, Aug 8, 2018.

  1. rpc

    rpc New Member

    Level: Professional
    I have an element that contains a value in the form:
    ["208", "220", "230", "240", "380", "400", "416", "440", "460", "480", "500", "550", "575", "600"]
    Each entry can contain different sequences of numbers. The dropdown nicely displays the unique set of values that are used in this field across all entries, but they are not in sorted order. How can I get them in numerical order?
     
  2. rpc

    rpc New Member

    Level: Professional
    Is further clarification needed?
     
  3. troester

    troester Well-Known Member Staff Member

    Level: Standard
    You can drag and drop the order of your suboptions in the element settings.
     
  4. rpc

    rpc New Member

    Level: Professional
    In the element - list view settings - filters, I specified a filter type of dropdown and order by of label.
    Where is the suboptions that I am dragging & dropping?
    What is not in numerical order is the list of values displayed in the dropdown for the specific field. See attached.
     

    Attached Files:

  5. troester

    troester Well-Known Member Staff Member

    Level: Standard
    So it's a dropdown element, in the list filter the labels are ordered correctly?
    And the issue is in the form's dropdown?
    You can order your dropdown options by dragging the upload_2018-8-12_0-14-2.png

    upload_2018-8-12_0-13-22.png
     
  6. rpc

    rpc New Member

    Level: Professional
    The dropdown.png in my previous post reflects what is seen when looking at the list filter, so no, it is not ordered correctly in that view.

    Where is that form's dropdown you reference? I don't see that "Renders Drop down / multiple select box" under Forms anywhere.
     
  7. troester

    troester Well-Known Member Staff Member

    Level: Standard
    It's in the element settings if it's a dropdown element, is it a dropdown?
    I'm not sure about your setup: is this what you are seeing directly in the database?
     
  8. rpc

    rpc New Member

    Level: Professional
    Yes, the database field contains quoted numbers, separated by commas, wrapped by square brackets:
    ["208", "220", "230", "240", "380", "400", "416", "440", "460", "480", "500", "550", "575", "600"]
    Attached are the Fabrik configuration screens.
     

    Attached Files:

  9. rpc

    rpc New Member

    Level: Professional
    Each database entry could contain a different list of values in that field, for example, here are four different entries:
    ["208", "220", "230", "240", "380", "400", "416", "440", "460", "480", "500", "550", "575", "600"]
    ["230", "460", "550", "575", "600"]
    ["550", "575", "600"]
    ["380"]
     
  10. troester

    troester Well-Known Member Staff Member

    Level: Standard
    So you have a simple field element holding JSON strings.
    I assume it's only by chance that this is interpreted as "repeat data" and shown so nicely formatted.
    A field element with text format is usually just a string.

    @cheesegrits ?
     
  11. rpc

    rpc New Member

    Level: Professional
    Is there another way to store this in the database or another element type definition, to make this work?
    Or is there a way I can define a separate sorted list of values used only for the dropdown?
     
  12. troester

    troester Well-Known Member Staff Member

    Level: Standard
    Is this a fixed number of values?
    How are they filled in (I assume the user is not typing such strings)?
    What do you need?

    It may be possible to use a multiselect dropdown element
    or a multiselect (or rendered as checkbox) dbjoin element (which is more flexible).

    Is this "live" data which must be converted if you are changing e.g. the element type?
    Or are you just testing?
     
  13. rpc

    rpc New Member

    Level: Professional
    Yes, the total number of unique numbers would be fixed, but each database entry can have a variable number of values as shown in my previous post.
    I am placing these values directly into the database, users of this data do not do any input/modify of this field. This field is not displayed to the user, it is only used for this filter behavior.
    This is not live data.

    The current format of the data allows me to filter on one specific value (via the dropdown, exact match=no), and it returns all entries that contain that one value.
    I need that dropdown (dropdown.png attached to the previous post) to list all these values in numerical order.
     
  14. troester

    troester Well-Known Member Staff Member

    Level: Standard
    It you want to have such JSON strings stored in the DB you can use a checkbox element or a dropdown element (with multiselections enabled).
    It's storing the values, you can set the labels as you like. The labels will be shown in the filter dropdown.
     
  15. rpc

    rpc New Member

    Level: Professional
    Yes, the dropdown now lists all the values in numerical order, but the "All" option is no longer listed in the dropdown. Is there a way to add that back in?
     
  16. rpc

    rpc New Member

    Level: Professional
    Ok, I figured out how to add the "All" option back into the dropdown, I needed to add each value into the Sub options list (then "All" magically appeared at the top).
    How do I get it to use the sub option list sequence in the dropdown?
    I've tried different options, but I couldn't get it to conform to the sub option sequence.
    See the attached sub option list sequence and dropdown sequence.
     

    Attached Files:

  17. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    Have you tried setting the "Order by" in the List Settings -> Filters to "None"?

    -- hugh
     
  18. rpc

    rpc New Member

    Level: Professional
    I had tried "None", but now I also modified "Filter data" to "Show all", and that worked. Thanks!
    Is there any other way to get the "All" value shown in the dropdown without having to fill in all the values as sub options?
     
  19. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    Nope.

    -- hugh
     
  20. rpc

    rpc New Member

    Level: Professional
    Okay, thank you very much for all your help!
     
    cheesegrits likes this.

Share This Page