Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Form Control => List - Select in the same sort order as the value map passed in?

    I have some troubles with the order of value map. I don't understand why it is re-sorting it based on the keys of the map.

    // This my code
    isc.DynamicForm.create({
    width: 550,
    wrapItemTitles:false,
    fields: [{
    name: "shipTo", title: "Ship to", type: "select",
    hint: "Overnight shipping available for countries in bold",
    wrapHintText: false,
    valueMap: {
    "01" : "1",
    "02" : "2",
    "03" : "3",
    "04" : "4",
    "05" : "5",
    "90" : "6",
    "95" : "7"

    },
    imageURLPrefix:"flags/16/",
    imageURLSuffix:".png"
    }]
    });

    But this is output: 6, 7, 1, 2, 3, 4, 5. it is re-sorting :((Click image for larger version  Name:	error.png Views:	0 Size:	44.7 KB ID:	269640

    How can i control it? Expected output: 1 ,2 , 3 ,4 ,5 ,6, 7
    Last edited by tranchiencongdemo; 17 Feb 2023, 02:02.

    #2
    JavaScript iteration order for object-keys does follow a certain set of rules since ES2015, but it's not necessarily the insertion order or string sort order, and it can differ by browser.

    You should be able to get the order you want by changing the keys - for example, by removing the leading "0" characters, like "1", or prefixing the keys with a character, like "C01".

    Comment


      #3
      Originally posted by Isomorphic View Post
      JavaScript iteration order for object-keys does follow a certain set of rules since ES2015, but it's not necessarily the insertion order or string sort order, and it can differ by browser.

      You should be able to get the order you want by changing the keys - for example, by removing the leading "0" characters, like "1", or prefixing the keys with a character, like "C01".
      Thank u, i just want to maintain the ordering from the value map I set on it. how can i do that without changing the keys
      Last edited by tranchiencongdemo; 16 Feb 2023, 00:59.

      Comment


        #4
        Add pickListProperties: { sortField: "shipTo" },

        Comment


          #5
          Originally posted by Isomorphic View Post
          Add pickListProperties: { sortField: "shipTo" },
          thank u
          Last edited by tranchiencongdemo; 16 Feb 2023, 01:22.

          Comment


            #6
            Originally posted by Isomorphic View Post
            Add pickListProperties: { sortField: "shipTo" },
            But it's really order by value. how can i handle it to order by key or maintain the ordering from the value map I set on it ?
            Last edited by tranchiencongdemo; 16 Feb 2023, 17:27.

            Comment


              #7
              Hi tranchiencongdemo,

              Make it a clientOnly DataSource with two or three fields. Then you can order by the key (or a third artificial key, if needed) and set displayField and valueField.

              Best regards
              ​​​​​​​Blama

              Comment


                #8
                Originally posted by Blama View Post
                Hi tranchiencongdemo,

                Make it a clientOnly DataSource with two or three fields. Then you can order by the key (or a third artificial key, if needed) and set displayField and valueField.

                Best regards
                Blama
                thank you but i dont know do that u can give me some examples ?
                ​​​​​​​// This my code
                isc.DynamicForm.create({
                width: 550,
                wrapItemTitles:false,
                fields: [{
                name: "shipTo", title: "Ship to", type: "select",
                hint: "Overnight shipping available for countries in bold",
                wrapHintText: false,
                valueMap: {
                "01" : "7",
                "02" : "2",
                "03" : "3",
                "04" : "4",
                "05" : "5",
                "90" : "6",
                "95" : "1"

                },
                imageURLPrefix:"flags/16/",
                imageURLSuffix:".png"
                }]
                });

                Comment


                  #9
                  Not on a computer, but a phone.
                  Look up clientOnly DataSource samples in the online showcase. Then use that DataSource for your item. Define two or three pickListFields and sort as you want.

                  Best regards
                  Blama

                  Comment

                  Working...
                  X