The below example demonstrates remote data filtering with column headers.
The dropdown options are filled from the grid data and initial filtering is also applied in the load event.

Shipping Orders
 
ShipCountry
Customer Name
Order ID
Order Date
Shipping Region
Paid
Shipping Via
Required Date
Shipped Date
Freight
Shipping Name
 
-
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
No rows to display.
Loading...


136
 
1
2
    $(function () {
3
4
        function pqDatePicker(ui) {
5
            var $this = $(this);
6
            $this
7
                //.css({ zIndex: 3, position: "relative" })
8
                .datepicker({
9
                    yearRange: "-25:+0", //25 years prior to present.
10
                    changeYear: true,
11
                    changeMonth: true,
12
                    showButtonPanel: true,
13
                    onClose: function (evt, ui) {
14
                        $(this).focus();
15
                    }
16
                });
17
            //default From date
18
            $this.filter(".pq-from").datepicker("option", "defaultDate", new Date("01/01/1996"));
19
            //default To date
20
            $this.filter(".pq-to").datepicker("option", "defaultDate", new Date("12/31/1998"));
21
        }
22
23
        //define colModel
24
        var colM = [
25
        { title: "ShipCountry", width: 100, dataIndx: "ShipCountry",
26
            filter: { type: 'textbox', condition: 'begin', listeners: ['change'] }
27
        },
28
        { title: "Customer Name", width: 120, dataIndx: "ContactName",
29
            filter: { type: 'textbox', condition: 'begin', listeners: ['change'] }
30
        },
31
        { title: "Order ID", minWidth: 130, dataIndx: "OrderID", dataType: "integer",
32
            filter: { type: 'textbox', condition: "between", listeners: ['change'] }
33
        },
34
        { title: "Order Date", minWidth: "190", dataIndx: "OrderDate", dataType: "date",
35
            filter: { type: 'textbox', condition: "between", init: pqDatePicker, listeners: ['change'] }
36
        },
37
        { title: "Shipping Region", width: 130, dataIndx: "ShipRegion",
38
            filter: { type: 'select',
39
                condition: 'equal', 
40
                //init: multiSelect,
41
                valueIndx: "ShipRegion",
42
                labelIndx: "ShipRegion",
43
                groupIndx: "ShipCountry",
44
                prepend: { '': '--Select--' },
45
                listeners: ['change']
46
            }
47
        },
48
        { title: "Paid", width: 100, dataIndx: "paid", dataType: "bool", align: "center", type: 'checkbox',
49
            filter: { type: "checkbox", subtype: 'triple', condition: "equal", listeners: ['click'] }
50
        },
51
        { title: "Shipping Via", width: 140, dataIndx: "ShipVia",
52
            filter: { type: "select",
53
                condition: 'equal',
54
                prepend: { '': '--Select--' },
55
                valueIndx: "ShipVia",
56
                labelIndx: "ShipVia",
57
                listeners: ['change']
58
            }
59
        },
60
        { title: "Required Date", width: 100, dataIndx: "RequiredDate", dataType: "date" },
61
        { title: "Shipped Date", width: 100, dataIndx: "ShippedDate", dataType: "date" },
62
        { title: "Freight", width: 100, align: "right", dataIndx: "Freight", dataType: "float" },
63
        { title: "Shipping Name", width: 150, dataIndx: "ShipName" },
64
        { title: "Shipping Address", width: 270, dataIndx: "ShipAddress" },
65
        { title: "Shipping City", width: 100, dataIndx: "ShipCity" },
66
        { title: "Shipping Postal Code", width: 180, dataIndx: "ShipPostalCode" }
67
68
        ];
69
        //define dataModel
70
        var dataModel = {
71
            location: "remote",            
72
            dataType: "JSON",
73
            method: "GET",
74
            url: "/pro/orders/get"
75
            //url: "/pro/orders.php",//for PHP
76
        }
77
        var obj = {
78
            height: 500,
79
            dataModel: dataModel,
80
            flex:{one: true},
81
            colModel: colM,
82
            //pageModel: { type: 'local', rPP: 20 },
83
            virtualX: true, virtualY: true,
84
            wrap: false,
85
            showBottom: false,            
86
            editable: false,            
87
            filterModel: { on: true, mode: "AND", header: true, type: 'remote' },
88
            title: "Shipping Orders",
89
            resizable: true,
90
            hwrap:false,
91
            freezeCols: 2,
92
            toolbar:{
93
                items:[
94
                    {
95
                        type:'button',
96
                        label: 'Toggle filter row',
97
                        listener: function(){
98
                            this.option('filterModel.header', !this.option('filterModel.header'));
99
                            this.refresh();
100
                        }
101
                    },
102
                    {
103
                        type:'button',
104
                        label: 'Reset filters',
105
                        listener: function(){
106
                            this.reset({filter: true});                         
107
                        }                        
108
                    }
109
                ]
110
            }
111
        };
112
        var grid = pq.grid( "#grid_filter", obj);
113
        
114
        //load shipregion and shipvia dropdowns in first load event.                
115
        grid.one("load", function (evt, ui) {
116
            var column = grid.getColumn({ dataIndx: "ShipRegion" });
117
            var filter = column.filter;
118
            filter.cache = null;
119
            filter.options = grid.getData({ dataIndx: ["ShipCountry", "ShipRegion"] });
120
121
            var column = grid.getColumn({ dataIndx: "ShipVia" });
122
            var filter = column.filter;
123
            filter.cache = null;
124
            filter.options = grid.getData({ dataIndx: ["ShipVia"] });
125
126
            //and apply initial filtering.
127
            grid.filter({
128
                oper: 'add',
129
                data: [
130
                    { dataIndx: 'ShipRegion', value: 'RJ' },
131
                    { dataIndx: 'ContactName', value: 'M' }
132
                ]
133
            });            
134
        });
135
    });
136
PrevNext
SuMoTuWeThFrSa
      1
2345678
9101112131415
16171819202122
23242526272829
3031