-
Notifications
You must be signed in to change notification settings - Fork 404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add column filters component #821
base: master
Are you sure you want to change the base?
Changes from all commits
abe7c1d
3ba3758
bc4f547
f76e9bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
<button @click="expandAll">Expand All</button> | ||
<button @click="collapseAll">Collapse All</button> | ||
<vue-good-table | ||
id="vgt-root" | ||
:columns="columns" | ||
:rows="rows" | ||
:line-numbers="true" | ||
|
@@ -28,6 +29,9 @@ | |
}" | ||
styleClass="vgt-table condensed bordered" | ||
ref="groupedTable" | ||
:column-filter-options="{ | ||
enabled: true | ||
}" | ||
> | ||
<!-- <template slot="table-header-row" slot-scope="props"> | ||
<span v-if="props.row.mode === 'span'"> | ||
|
@@ -37,11 +41,17 @@ | |
{{props.formattedRow[props.column.field]}} | ||
</span> | ||
</template> --> | ||
|
||
<template v-slot:table-actions-dropdown="{columns}"> | ||
<vgt-column-dropdown :columns="columns" /> | ||
</template> | ||
</vue-good-table> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import VgtColumnDropdown from '../src/components/plugins/VgtColumnDropdown.vue'; | ||
|
||
export default { | ||
name: 'grouped-table', | ||
props: [], | ||
|
@@ -54,6 +64,7 @@ export default { | |
filterOptions: { | ||
enabled: true, | ||
}, | ||
hidden: false, | ||
}, | ||
{ | ||
label: 'Diet', | ||
|
@@ -66,6 +77,7 @@ export default { | |
field: 'count', | ||
headerField: this.sumCount, | ||
type: 'number', | ||
hidden: false, | ||
}, | ||
], | ||
rows: [ | ||
|
@@ -135,12 +147,42 @@ export default { | |
mounted() { | ||
}, | ||
components: { | ||
VgtColumnDropdown | ||
}, | ||
}; | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.row-style{ | ||
background-color: red; | ||
.row-style { | ||
background-color: red; | ||
} | ||
|
||
#vgt-root >>> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried applying a little example styling. But it won't work. |
||
.vgt-dropdown { | ||
float: right; | ||
margin-bottom: 5px; | ||
} | ||
|
||
ul.vgt-dropdown-menu { | ||
position: absolute; | ||
float: left; | ||
min-width: 160px; | ||
padding: 5px 0; | ||
margin: 2px 0 0; | ||
font-size: 14px; | ||
text-align: left; | ||
list-style: none; | ||
background-clip: padding-box; | ||
border-radius: 4px; | ||
|
||
li > span { | ||
display: block; | ||
padding: 3px 20px; | ||
clear: both; | ||
font-weight: 400; | ||
line-height: 1.42857143; | ||
white-space: nowrap; | ||
} | ||
} | ||
} | ||
</style> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<template> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @xaksis I think this is the best we can do to separate features from the core functionality. Imo I think we should gradually move some of the components to the plugins folder. So the user can use those, extend from it. Or drop in something entirely different. If you want to move to something that's for ex renderless, that's possible. But that would require a total rewrite. And imo I think Vue3's composition API could shine there. Abstracting out render related functions. I think you can decrease maintenance costs, by utilizing scoped slots more, and having some example components in plugins. That way, you could put the MVP in plugins, while offering a lot of flexibility to the user. |
||
<div class="vgt-dropdown vgt-clearfix"> | ||
<!-- Drowdown with checkboxes for showing / hiding table headers --> | ||
<div class="button-group pull-right"> | ||
<button type="button" class="btn btn-default btn-sm dropdown-toggle" @click="selectOpen = !selectOpen"><span class="fa fa-cog" aria-hidden="false">Select Columns</span> <span class="caret" /></button> | ||
<ul v-show="selectOpen" class="vgt-dropdown-menu"> | ||
<li v-for="(column, index) in filteredColumns" :key="index"> | ||
<span class="small" tabIndex="-1"> | ||
<input :ref="`filterlabel${column.label}`" :checked="!column.hidden" @change.prevent="updateFilteredColumn(column.label, $event.target.checked)" type="checkbox"> | ||
{{column.label}} | ||
</span> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'vgtColumnDropdown', | ||
props: [ | ||
'columns', | ||
], | ||
data() { | ||
return { | ||
filteredColumns: [], | ||
selectOpen: false | ||
} | ||
}, | ||
mounted() { | ||
const { parentProps } = this; | ||
console.log(parentProps); | ||
}, | ||
methods: { | ||
updateFilteredColumn(label, checked) { | ||
this.columns.find(column => column.label === label).hidden = !checked; | ||
} | ||
}, | ||
watch: { | ||
columns: { | ||
handler() { | ||
const { columns } = this; | ||
this.filteredColumns = columns.filter(column => column.hidden !== undefined); | ||
}, | ||
deep: true, | ||
immediate: true, | ||
}, | ||
} | ||
}; | ||
</script> | ||
|
||
<style> | ||
</style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Three lines to utilize the column filter, but a user can drop-in his own component if he likes.