Author Topic: select input with valueIndx and lableIndx  (Read 3431 times)

angelahlp

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 51
    • View Profile
select input with valueIndx and lableIndx
« on: May 15, 2015, 03:28:49 am »
Hello - I'm trying to set an INT for the value and the text for the label - I'm using the following but it's not working - the array that is passed for the options is a JSON array. I'm using version 2.3 - if this doesn't work until 2.4 - is there another way to do this with earlier versions?

          { title: "SELECT NAME",  dataIndx: "selectid",
            editor: {
               type: 'select',
               options: arrSelect,
               valueIndx: "selectid",
               labelIndx: "selectname"
            }
         },

Any Help is Appreciated --

Thanks,
Angela

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: select input with valueIndx and lableIndx
« Reply #1 on: May 15, 2015, 08:27:43 pm »
This is supposed to work even in 2.3.0

The JSON format should be correct.

[{ "selectid": id1, "selectname": "value1"}, ...]

angelahlp

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 51
    • View Profile
Re: select input with valueIndx and lableIndx
« Reply #2 on: June 24, 2015, 12:22:32 pm »
I've come back to this and still need help. The problem I am having is that after I select an option in the drop down the value turns into the id - instead of staying as the string value. It is also not sending the value of the id when an update is made.

The json string is:
[{"commandid":6,"command":"Talk"},{"commandid":5,"command":"Sit"},{"commandid"
:16,"command":"stand"},{"commandid":14,"command":"bark"}]

The code I'm currently trying is below. I've tried many variations with no luck:
{ dataIndx: "commandid", hidden: true },
{ title: "Type", minWidth: 30, width: 100, dataIndx: "command",
editor: {
type: 'select',
options: arrCommands,
mapIndices: {"name": "command", "id": "commandid"},
valueIndx: "command",
labelIndx: "command"
}
},

I would appreciate it if you could give me some insight on what I'm doing wrong here :) TIA!

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: select input with valueIndx and lableIndx
« Reply #3 on: June 24, 2015, 08:30:04 pm »
mapIndices is not supported in 2.4.x but that doesn't seem to be required in your case.

you have kept valueIndx and labelIndx to be same, is it intentional in that you don't need id in select list?

If you are interested in string values only, you may also keep options format as array of strings.
[ "Talk", "Sit", "stand", ....]

It would be great if you could share a small jsfiddle if you are still facing issues.
http://jsfiddle.net/paramquery/0g30xsv4/1/