0

Definition of my variable is

var vykazyMesice =  { 
  '01': "leden - 01",
  '02': "únor - 02",
  '03': "březen - 03",
  '04': "duben - 04",
  '05': "květen - 05",
  '06': "červen - 06",
  '07': "červenec - 07",
  '08': "srpen - 08",
  '09': "září - 09",
  '10': "říjen - 10",
  '11': "lispopad - 11",
  '12': "prosinec - 12",
  } 

but when used in Tabulator autocomplete the order is different.

https://i.imgur.com/4UzJYoL.pn

working jsFiddle

If you check console.log() output in a browser console then you can see the two orders. Not sure how to name them but they are different. The first one you can see in the Tabulator. The second one is the one I want to see in my application.

enter image description here

Someone would know how to use the order I want? The order in variable definition.

Radek
  • 13,813
  • 52
  • 161
  • 255
  • 1
    the order is by defuinition first index like positive integers up to 32 bit, then all other values in insertation order and at the end all symbols. if you need a defined order, take an array. – Nina Scholz Jan 14 '22 at 14:54
  • could you point me to the definition? More importantly. How can I use an array if I have to pass an object? – Radek Jan 14 '22 at 15:00
  • `I have to pass an object` But you don't. `values: true | string[] | JSONRecord | string | any[];` – Roberto Zvjerković Jan 14 '22 at 15:04
  • please have a look here: https://stackoverflow.com/questions/30076219/does-es6-introduce-a-well-defined-order-of-enumeration-for-object-properties another solution is to use numbers without leading zeroes ad apply the zeroes later. – Nina Scholz Jan 14 '22 at 15:13
  • @NinaScholz what do you mean by later? – Radek Jan 14 '22 at 15:27
  • @RobertoZvjerković could you please explain? I do not understand what you meant – Radek Jan 14 '22 at 15:28
  • i mean, if you need formatted keys , you could apply it to a numerical value. – Nina Scholz Jan 14 '22 at 16:02

1 Answers1

0

Regarding the comments there might be more solutions but if I read manual carefully I would have known this

You can also pass in an array of objects, that allows you to define option in order. -- from Tabulator doc working jsFiddle

  var vykazyMesice =  [
        { 
            label:"leden - 01",
            value:"01",
        },
        {
            label:"únor - 02",
            value:"02",
        },
        {
            label:"březen - 03",
            value:"03",
        },
        {
            label:"duben - 04",
            value:"04",
        },
        {
            label:"květen - 05",
            value:"05",
        },
        {
            label:"červen - 06",
            value:"06",
        },
        {
            label:"červenec - 07",
            value:"07",
        },
        {
            label:"srpen - 08",
            value:"08",
        },
        {
            label:"září - 09",
            value:"09",
        },
        {
            label:"říjen - 10",
            value:"10",
        },
        {
            label:"listopad - 11",
            value:"11",
        },
        {
            label:"prosinec - 12",
            value:"12",
        },
    ]
  
  
Radek
  • 13,813
  • 52
  • 161
  • 255