Select2 plugin with JQGRID

1.3k Views Asked by At

I am using Select2 plugin in JQgrid to auto complete the Drop down box.I used this example to work through.

Using bootstrap select2 with JqGrid form

I created a fiddle with the above example. http://jsfiddle.net/VTL4x/3/

The data for the select2 is fed from JSON but I am not able to replicate it in JSfiddle so I have commented out the and used hard coded values.

The Json string is

[{"value":"Windows","id":"134"},
{"value":"Win2008","id":"135"},
{"value":"Win2003","id":"136"},
{"value":"AIX","id":"150"},
{"value":"Linux","id":"151"},
{"value":"Unknown","id":"152"},
{"value":"i5OS","id":"153"},
{"value":"z/OS","id":"154"},
{"value":"Solaris","id":"155"},
{"value":"Sun Ultra 80 ","id":"156"},
{"value":"VAX","id":"157"}]

The problem is When I try to edit the record it does NOT show the values for the fields that have Select2 dropdown box. but when you expend I could see that correct values highlighted in blue.

I tried to debug the demo that was provided but that also had the same problem.

I am fairly new to front-end programming can you please help.

Thanks for your help

1

There are 1 best solutions below

0
On

Which version of select2 you're using? I'm using v4 so your data should look like this:

var mySelectData = [{"text":"Windows","id":"134"},
{"text":"Win2008","id":"135"},
{"text":"Win2003","id":"136"},
{"text":"AIX","id":"150"},
{"text":"Linux","id":"151"},
{"text":"Unknown","id":"152"},
{"text":"i5OS","id":"153"},
{"text":"z/OS","id":"154"},
{"text":"Solaris","id":"155"},
{"text":"Sun Ultra 80 ","id":"156"},
{"text":"VAX","id":"157"}];

Use text instead of value.