How to load options for select lists remotely?

Column Ship Country has select editor with remote data in array format being fetched from server in create event via $.getJSON and assigned to column.editor.options.

[ "USA", "Afghanistan", "Akrotiri", "Albania", "Algeria", ...]

Column Shipping Via has select editor with remote data in JSON format being fetched from server in create event via $.getJSON and assigned to column.editor.options.

[
    {"value": "", "text": ""},  
    {"value": "SE", "text": "Speedy Express" }, 
    {"value": "UP", "text": "United Package" }, 
    {"value": "FS", "text": "Federal Shipping"}
]
Shipping Orders (Custom editing)
Ship Country
Shipping Via
Order ID
 
 
 
No rows to display.
Loading...


70
 
1
2
    $(function () {
3
        //optional function used to create pqSelect and auto open it.
4
        function initSelect(ui) {
5
            ui.$cell.find("select").pqSelect();
6
            setTimeout(function () {
7
                ui.$cell.find("select").pqSelect('open');
8
            })
9
        }
10
        var colModel = [
11
            { title: "Ship Country", dataIndx: "ShipCountry", width: 120,
12
                editor: {
13
                    type: "select",
14
                    init: initSelect,
15
                    options: []
16
                }
17
            },
18
            {
19
                title: "Shipping Via",
20
                dataIndx: "ShipVia",
21
                width: 110,
22
                editor: {
23
                    type: 'select',
24
                    init: initSelect,
25
                    valueIndx: "value",
26
                    labelIndx: "text",
27
                    options: [],
28
                    //mapIndices: { "text": "ShipVia", "value": "ShipViaId" }
29
                },
30
                //render required to display options text corresponding to value stored in the cell.
31
                render: function (ui) {
32
                    var option = ui.column.editor.options.find(option => option.value == ui.cellData);
33
                    return option? option.text: "";
34
                }
35
            },
36
            { title: "Order ID", width: 100, dataIndx: "OrderID", editable: false }
37
        ];
38
        
39
        $("#grid_custom_editing").pqGrid({
40
            colModel: colModel,
41
            create: function (evt, ui) {
42
                var grid = this,
43
                    column;
44
45
                //fetch options for ShipCountry column from server.
46
                $.getJSON("/pro/demos/getCountries", function (response) {
47
                    column = grid.getColumn({ dataIndx: 'ShipCountry' });
48
                    column.editor.options = response;
49
                });
50
51
                //fetch options for ShipVia column from server.
52
                $.getJSON("/Content/ShipVia.json", function (response) {
53
                    column = grid.getColumn({ dataIndx: 'ShipVia' });
54
                    column.editor.options = response;
55
                });
56
            },
57
            dataModel: {
58
                dataType: "JSON",
59
                location: "remote",
60
                method: "GET",
61
                url: "/content/invoice.json"
62
            },
63
            historyModel: { checkEditable: false },
64
            numberCell: { show: false },
65
            resizable: true,
66
            scrollModel: { autoFit: true },
67
            title: "Shipping Orders <b>(Custom editing)</b>"
68
        });
69
    });
70
ParamQuery Pro Eval