Author Topic: Dropdown list from JSON data  (Read 2248 times)

zerocool78

  • Newbie
  • *
  • Posts: 1
    • View Profile
Dropdown list from JSON data
« on: January 25, 2016, 09:28:51 pm »
Hi,

I have successfully got my grid up and running using a "local" array of JSON data which I will then post back to my SQL server once changes have been confirmed.

I am now trying to implement a dropdown list in one of my columns (Branches) again using JSON data.

I have tried using the following function (and various iterations) in the "option:" section but so far have come up blank (quite literally).

Any assistance would be gratefully received:

Code: [Select]
               
var branchdata;

/* additional pqGrid code here */

{ title: "Branch", width: 100, dataType: "string", align: "left", dataIndx: "BRANCH_CODE", editor:{type: 'select', option: $.getJSON("/admin/lookups/branches", function (brjson) {
                        branchdata = brjson;})
                        }}];
« Last Edit: January 25, 2016, 09:35:07 pm by zerocool78 »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Dropdown list from JSON data
« Reply #1 on: January 26, 2016, 10:37:25 am »
The returned JSON data should be bound to column.editor.options

Code: [Select]
$.getJSON("/admin/lookups/branches", function (brjson) {   
    column.editor.options = brjson;//where column is reference to required column in colModel.
});