Array data (Array of row arrays) can be directly passed as the value of data key in dataModel object.

Grid From Array
A
B
C
D
 
 
 
 
#
 
1
Exxon Mobil
339938.0
36130.0
2
Wal-Mart Stores
315654.0
11231.0
3
Royal Dutch Shell
306731.0
25311.0
4
BP
267600.0
22341.0
5
General Motors
192604.0
-10567.0
6
Chevron
189481.0
14099.0
7
DaimlerChrysler
186106.3
3536.3
8
Toyota Motor
185805.0
12119.6
9
Ford Motor
177210.0
2024.0
10
ConocoPhillips
166683.0
13529.0
11
General Electric
157153.0
16353.0
12
Total
152360.7
15250.0
13
ING Group
138235.3
8958.9
14
Citigroup
131045.0
24589.0
15
AXA
129839.2
5186.5
16
Allianz
121406.0
5442.4
17
Volkswagen
118376.6
1391.7
18
Fortis
112351.4
4896.3
19
Crédit Agricole
110764.6
7434.3
20
American Intl. Group
108905.0
10477.0
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
rank
company
revenue
profits
1
Loading...


46
 
1
2
    $(function () {
3
        var data = [
4
            ['rank', 'company', 'revenue', 'profits'],
5
            [1, 'Exxon Mobil', '339938.0', '36130.0'],
6
            [2, 'Wal-Mart Stores', '315654.0', '11231.0'],
7
            [3, 'Royal Dutch Shell', '306731.0', '25311.0'],
8
            [4, 'BP', '267600.0', '22341.0'],
9
            [5, 'General Motors', '192604.0', '-10567.0'],
10
            [6, 'Chevron', '189481.0', '14099.0'],
11
            [7, 'DaimlerChrysler', '186106.3', '3536.3'],
12
            [8, 'Toyota Motor', '185805.0', '12119.6'],
13
            [9, 'Ford Motor', '177210.0', '2024.0'],
14
            [10, 'ConocoPhillips', '166683.0', '13529.0'],
15
            [11, 'General Electric', '157153.0', '16353.0'],
16
            [12, 'Total', '152360.7', '15250.0'],
17
            [13, 'ING Group', '138235.3', '8958.9'],
18
            [14, 'Citigroup', '131045.0', '24589.0'],
19
            [15, 'AXA', '129839.2', '5186.5'],
20
            [16, 'Allianz', '121406.0', '5442.4'],
21
            [17, 'Volkswagen', '118376.6', '1391.7'],
22
            [18, 'Fortis', '112351.4', '4896.3'],
23
            [19, 'Crédit Agricole', '110764.6', '7434.3'],
24
            [20, 'American Intl. Group', '108905.0', '10477.0']];
25
26
27
        var obj = {
28
            title: "Grid From Array",
29
            numberCell: { resizable: true, title: "#" },
30
            scrollModel: { autoFit: true },
31
            columnTemplate: { 
32
                title: function (ui) {
33
                    return ['A', 'B', 'C', 'D'][ui.colIndx];
34
                }
35
            },
36
            sortModel: {on : false},
37
            showBottom: false,
38
            freezeRows: 1,
39
            resizable: true,
40
            dataModel: { data: data }
41
        };
42
43
        var $grid = $("#grid_array").pqGrid(obj);
44
45
    });
46
    obj.cellMouseDown = function (evt, ui) {
        cons.log("mouse down");
        var val = ui.dataModel.data[ui.rowIndx][ui.colIndx];
        ui.dataModel.mousedown = { rowIndx: ui.rowIndx, colIndx: ui.colIndx, val: val };
    }
    obj.cellMouseMove = function (evt, ui) {
        if (ui.dataModel.mousedown) {
            ui.dataModel.data[ui.rowIndx][ui.colIndx] = ui.dataModel.mousedown.val;
            cons.log("mouse move rowIndx = " + ui.rowIndx + ", colIndx = " + ui.colIndx);
            $grid.pqGrid("selection", { type: 'cell', method: 'add', rowIndx: ui.rowIndx, colIndx: ui.colIndx });
            $grid.pqGrid("refreshCell", { rowIndx: ui.rowIndx, colIndx: ui.colIndx });
        }
    }
    obj.cellMouseUp = function (evt, ui) {
        cons.log("mouse up rowIndx = " + ui.rowIndx + ", colIndx = " + ui.colIndx);
        //get all selection
        //chnage the values 
        //refresh the column or row.
        ui.dataModel.mousedown = null;
    }

ParamQuery Pro Eval