1 | /* |
---|
2 | * Ext JS Library 2.2.1 |
---|
3 | * Copyright(c) 2006-2009, Ext JS, LLC. |
---|
4 | * licensing@extjs.com |
---|
5 | * |
---|
6 | * http://extjs.com/license |
---|
7 | */ |
---|
8 | |
---|
9 | Ext.grid.filter.StringFilter = Ext.extend(Ext.grid.filter.Filter, { |
---|
10 | updateBuffer: 500, |
---|
11 | icon: '/img/small_icons/famfamfam/find.png', |
---|
12 | |
---|
13 | init: function() { |
---|
14 | var value = this.value = new Ext.menu.EditableItem({icon: this.icon}); |
---|
15 | value.on('keyup', this.onKeyUp, this); |
---|
16 | this.menu.add(value); |
---|
17 | |
---|
18 | this.updateTask = new Ext.util.DelayedTask(this.fireUpdate, this); |
---|
19 | }, |
---|
20 | |
---|
21 | onKeyUp: function(event) { |
---|
22 | if(event.getKey() == event.ENTER){ |
---|
23 | this.menu.hide(true); |
---|
24 | return; |
---|
25 | } |
---|
26 | this.updateTask.delay(this.updateBuffer); |
---|
27 | }, |
---|
28 | |
---|
29 | isActivatable: function() { |
---|
30 | return this.value.getValue().length > 0; |
---|
31 | }, |
---|
32 | |
---|
33 | fireUpdate: function() { |
---|
34 | if(this.active) { |
---|
35 | this.fireEvent("update", this); |
---|
36 | } |
---|
37 | this.setActive(this.isActivatable()); |
---|
38 | }, |
---|
39 | |
---|
40 | setValue: function(value) { |
---|
41 | this.value.setValue(value); |
---|
42 | this.fireEvent("update", this); |
---|
43 | }, |
---|
44 | |
---|
45 | getValue: function() { |
---|
46 | return this.value.getValue(); |
---|
47 | }, |
---|
48 | |
---|
49 | serialize: function() { |
---|
50 | var args = {type: 'string', value: this.getValue()}; |
---|
51 | this.fireEvent('serialize', args, this); |
---|
52 | return args; |
---|
53 | }, |
---|
54 | |
---|
55 | validateRecord: function(record) { |
---|
56 | var val = record.get(this.dataIndex); |
---|
57 | if(typeof val != "string") { |
---|
58 | return this.getValue().length == 0; |
---|
59 | } |
---|
60 | return val.toLowerCase().indexOf(this.getValue().toLowerCase()) > -1; |
---|
61 | } |
---|
62 | }); |
---|