value is displaying instead of label in select dropdown inline edit

value is displaying instead of label in select dropdown inline edit

NandhaNNandhaN Posts: 1Questions: 1Answers: 0

Hi ,

Can any one help me to display label for select drop-down instead of values.

Thanks

Answers

  • rf1234rf1234 Posts: 2,802Questions: 85Answers: 406

    Let's assume you have these options for your select dropdown:

    var yourOpts = 
        [
            { label: "One", value: 1 },
            { label: "Three", value: 3 },
            { label: "Six", value: 6 },
            { label: "Eight", value: 8 }
        ];
    

    In your Editor instance you would have this:

    ....
    {
        label: 'my really nice field',
        name: "yourField",
        type: "select",
        options: yourOpts 
    }
    ....
    

    In the data table you would use rendering to display "One" etc. instead of 1 etc.

    ....
    {   data: "yourField",
        render: function (data, type, row) {
            return $.grep(yourOpts , function(obj){return obj.value == data;})[0].label;
        }
    },
    ....
    
  • rf1234rf1234 Posts: 2,802Questions: 85Answers: 406

    More details on the various options here:
    https://www.linkedin.com/pulse/javascript-find-object-array-based-objects-property-rafael/

    Some of them won't work in Internet Explorer though. The jQuery solution works in the latest (and final) IE version.

  • jaxx0rrjaxx0rr Posts: 1Questions: 0Answers: 0

    ty for this answer. I was hoping this obvious bug would be fixed by now but I take what I can get..

This discussion has been closed.