Responsive layout 1

ParamQuery Grid supports fluid layout whereby the grid width can be provided as 'auto' or as percent of the width of container block.

Column width can be provided as percent of the grid's width.

Grid and the columns resize themselves when the window is resized.

Grid From JSON
Rank (20%)
Company (35%)
Revenues (25%)
Profits (246)
 
 
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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Loading...

64
 
1
2
3
    $(function () {
4
        var data = [
5
            { rank: 1, company: 'Exxon Mobil', revenues: '339938.0', profits: '36130.0' },
6
            { rank: 2, company: 'Wal-Mart Stores', revenues: '315654.0', profits: '11231.0' },
7
            { rank: 3, company: 'Royal Dutch Shell', revenues: '306731.0', profits: '25311.0' },
8
            { rank: 4, company: 'BP', revenues: '267600.0', profits: '22341.0' },
9
            { rank: 5, company: 'General Motors', revenues: '192604.0', profits: '-10567.0' },
10
            { rank: 6, company: 'Chevron', revenues: '189481.0', profits: '14099.0' },
11
            { rank: 7, company: 'DaimlerChrysler', revenues: '186106.3', profits: '3536.3' },
12
            { rank: 8, company: 'Toyota Motor', revenues: '185805.0', profits: '12119.6' },
13
            { rank: 9, company: 'Ford Motor', revenues: '177210.0', profits: '2024.0' },
14
            { rank: 10, company: 'ConocoPhillips', revenues: '166683.0', profits: '13529.0' },
15
            { rank: 11, company: 'General Electric', revenues: '157153.0', profits: '16353.0' },
16
            { rank: 12, company: 'Total', revenues: '152360.7', profits: '15250.0' },
17
            { rank: 13, company: 'ING Group', revenues: '138235.3', profits: '8958.9' },
18
            { rank: 14, company: 'Citigroup', revenues: '131045.0', profits: '24589.0' },
19
            { rank: 15, company: 'AXA', revenues: '129839.2', profits: '5186.5' },
20
            { rank: 16, company: 'Allianz', revenues: '121406.0', profits: '5442.4' },
21
            { rank: 17, company: 'Volkswagen', revenues: '118376.6', profits: '1391.7' },
22
            { rank: 18, company: 'Fortis', revenues: '112351.4', profits: '4896.3' },
23
            { rank: 19, company: 'Crédit Agricole', revenues: '110764.6', profits: '7434.3' },
24
            { rank: 20, company: 'American Intl. Group', revenues: '108905.0', profits: '10477.0' }
25
        ];
26
27
        var obj = {            
28
            minWidth: 500,
29
            height: 400,
30
            resizable: true,
31
            scrollModel: { autoFit: true },
32
            title: "Grid From JSON",
33
            collapsible: { on: true, collapsed: false }
34
        };
35
        obj.columnTemplate = {            
36
            title: function (ui) {
37
                return ui.column.Title + " (" + ui.column.width + ")";
38
            }
39
        };
40
        obj.colModel = [
41
            { Title: "Rank", dataType: "integer", dataIndx: "rank", width: "20%" },
42
            { Title: "Company", dataType: "string", dataIndx: "company", width: "35%" },
43
            { Title: "Revenues", dataType: "float", dataIndx: "revenues", width:"25%" },
44
            { Title: "Profits", dataType: "float", dataIndx: "profits" }
45
        ];
46
        obj.dataModel = { data: data };
47
48
        var grid = pq.grid("#grid_json", obj);
49
        grid.on('refresh', function () {
50
            grid.refreshHeader()
51
        })
52
53
        //bind width to select list.
54
        $("#sl_width").change(function (evt) {
55
            var val = $(this).val();
56
            grid.option('width', val)
57
            grid.refresh();
58
        });
59
        $("#sl_margin").change(function (evt) {
60
            var val = $(this).val();
61
            grid.widget().css('margin', val).pqGrid('refresh');
62
        });
63
    });    
64
ParamQuery Pro Eval