/
filters.js
96 lines (91 loc) · 2.61 KB
/
filters.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/**
* Copyright (c) 2008-2011 The Open Planning Project
*
* Published under the GPL license.
* See https://github.com/opengeo/gxp/raw/master/license.txt for the full text
* of the license.
*/
var filter = new OpenLayers.Filter.Logical({
type: OpenLayers.Filter.Logical.OR,
filters: [
new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: 'population',
value: 1000
}),
new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.LESS_THAN,
property: "income",
value: 1000
})
]
});
var feWin = null;
var format = new OpenLayers.Format.Filter();
function showFE(panel) {
var filter = panel.getComponent(0).getFilter();
var node = format.write(filter);
var text = OpenLayers.Format.XML.prototype.write.apply(format, [node]);
if(!feWin) {
feWin = new Ext.Window({
title: "Filter Encoding",
layout: "fit",
closeAction: "hide",
height: 300,
width: 450,
plain: true,
modal: true,
items: [{
xtype: "textarea",
value: text
}]
});
} else {
feWin.items.items[0].setValue(text);
}
feWin.show();
}
Ext.onReady(function() {
Ext.QuickTips.init();
var panel1 = new Ext.Panel({
title: "Filter Builder (no groups)",
renderTo: "panel1",
width: 320,
items: [{
xtype: "gxp_filterbuilder",
style: "padding: .3em .3em .1em .1em",
allowGroups: false,
filter: filter.clone(),
attributes: new GeoExt.data.AttributeStore({
url: "data/describe_feature_type.xml",
ignore: {name: "the_geom"}
})
}],
bbar: ["->", {
text: "View Filter Encoding",
handler: function() {
showFE(panel1);
}
}]
});
var panel2 = new Ext.Panel({
title: "Filter Builder (with groups)",
renderTo: "panel2",
width: 320,
items: [{
xtype: "gxp_filterbuilder",
style: "padding: .3em .3em .1em .1em",
filter: filter.clone(),
attributes: new GeoExt.data.AttributeStore({
url: "data/describe_feature_type.xml",
ignore: {name: "the_geom"}
})
}],
bbar: ["->", {
text: "View Filter Encoding",
handler: function() {
showFE(panel2);
}
}]
});
});