Skip to content

Commit

Permalink
Added dropdown filter option (#56)
Browse files Browse the repository at this point in the history
Added dropdown filter option and updated README.md
  • Loading branch information
bmrankin authored and xaksis committed Sep 6, 2017
1 parent e9f1fe2 commit 03cc648
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,24 @@ data() {
</tr>
<tr>
<td>filterable (optional)</td>
<td>enables filtering on column</td>
<td>Boolean</td>
</tr>
<tr>
<td>filterTextInput (optional)</td>
<td>provides the column with a filter input</td>
<td>Boolean</td>
</tr>
<tr>
<td>filterDropdown (optional)</td>
<td>provides a dropdown for filtering</td>
<td>Boolean</td>
</tr>
<tr>
<td>filterOptions (required for filterDropdown)</td>
<td>provides options to dropdown filter <code>filterOptions: ['Blue', 'Red', 'Yellow']</code></td>
<td>Array</td>
</tr>
<tr>
<td>filter (optional)</td>
<td>Custom filter, function of two variables: <code>function(data, filterString)</code>,
Expand Down
16 changes: 13 additions & 3 deletions src/components/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,19 @@
<tr v-if="hasFilterRow">
<th v-if="lineNumbers"></th>
<th v-for="(column, index) in columns">
<input v-if="column.filterable" type="text" class="form-control" v-bind:placeholder="'Filter ' + column.label"
v-bind:value="columnFilters[column.field]"
v-on:input="updateFilters(column, $event.target.value)">
<div v-if="column.filterable">
<input v-if="column.filterTextInput"
type="text" class="form-control" :placeholder="'Filter ' + column.label"
:value="columnFilters[column.field]"
v-on:input="updateFilters(column, $event.target.value)">

<select v-if="column.filterDropdown" class="form-control"
:value="columnFilters[column.field]"
v-on:input="updateFilters(column, $event.target.value)">
<option value=""></option>
<option v-for="option in column.filterOptions" :value="option">{{ option }}</option>
</select>
</div>
</th>
</tr>
</thead>
Expand Down

0 comments on commit 03cc648

Please sign in to comment.