forked from vaadin/vaadin-grid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvaadin-grid-filter.html
76 lines (62 loc) · 1.74 KB
/
vaadin-grid-filter.html
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
<!--
@license
Copyright (c) 2017 Vaadin Ltd.
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
-->
<!--
`vaadin-grid-filter` is a helper element for the `vaadin-grid` that provides out-of-the-box UI controls,
and handlers for filtering the grid data.
-->
<link rel="import" href="../polymer/polymer.html">
<dom-module id="vaadin-grid-filter">
<template>
<style>
:host {
display: inline-flex;
}
#filter {
width: 100%;
box-sizing: border-box;
}
</style>
<slot name="filter">
<input id="filter" value="{{value::input}}">
</slot>
</template>
<script>
Polymer({
is: 'vaadin-grid-filter',
properties: {
/**
* JS Path of the property in the item used for filtering the data.
*/
path: String,
/**
* Current filter value.
*/
value: {
type: String,
notify: true
}
},
observers: ['_filterChanged(path, value, isAttached)'],
ready: function() {
var child = Polymer.dom(this).firstElementChild;
if (child && child.getAttribute('slot') !== 'filter') {
console.warn('Make sure you have assigned slot="filter" to the child elements of <vaadin-grid-filter>');
child.setAttribute('slot', 'filter');
}
},
_filterChanged: function(path, value, isAttached) {
if (path === undefined || value === undefined || isAttached === undefined) {
return;
}
if (isAttached) {
this.debounce('filter-changed', function() {
this.fire('filter-changed');
}, 200);
}
}
});
</script>
</dom-module>