Display select dropdown "name" value instead of "id" value.
Display select dropdown "name" value instead of "id" value.
davykiash
Posts: 35Questions: 13Answers: 1
Hello,
Am using the select2 plugin to display dropdown information from a table. Instead of having the table display the name e.g. "1 (highest)" it displays the id "1". What options do I need to set/adjust to achieve it?
My code
{
label: "Rule:",
name: "price_list_link_rule_id",
type: "select2",
options: [
{ name: "1 (highest)", id: "1" },
{ name: "2 (Mid)", id: "2" },
{ name: "3 (Level)", id: "3" },
{ name: "4 (Good)", id: "4" },
{ name: "5 (lowest)", id: "5" }
],
optionsPair: {
label: 'name',
value: 'id'
}
/*
options: [
{ "label": "1 (highest)", "value": "1" },
{ "label": "2", "value": "2" },
{ "label": "3", "value": "3" },
{ "label": "4", "value": "4" },
{ "label": "5 (lowest)", "value": "5" }
]
*/
}
This discussion has been closed.
Replies
Like this? http://jsbin.com/mamuxig/edit?html,js,output
It puts a select2 using the data set above, though, when you push data directly into select2, it will be an array of text: "" , id: "" as shown at the link
Hello @bindrid
Please check the source below. The solution you provided partially works.
Yes I can display the select2 plugin inline but the values do not change and the select2 should be visible one the user clicks to edit.
My Javascript
My HTML
Server Side
Please assist
I'm not clear on why you are using
return "<select></select>";
in a renderer for that column? If you want Select2 to show when the user clicks on the cell, drop that and just keep theinline()
call.Could you link to the page so I can check it out and see if I can see why the correct value isn't being selected please?
Thanks,
Allan
Hello @allan
I have pasted my full source at http://jsbin.com/cusoteb/edit?html,js,output.
All I need is for the column "Item Category" to be select2 enabled for editing. On display it should display the "Category Description" and not the "Category UUID"
Thanks.
Change:
to be:
Allan
@allan Perfect!