
Security News
NVD Quietly Sweeps 100K+ CVEs Into a “Deferred” Black Hole
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.
vuetable-django
Advanced tools
vue.js table component that will automatically request JSON data from server and display them nicely in HTML table with swap-able/extensible pagination component. This is the django-restframework backend modification version.
--- Not complete yet. Dont use this version now.
这个是vuetable的django后台改造版本。针对 django-restframework的翻页需求,改造vue-table,使之用最少的配置,就可以搭配rest后台。 改造中尽可能少侵入原代码。以保证良好的可升级性。 感谢@ratiw,原始代码结构非常好,很容易改造。
vuetable
tagvuetable
to manipulate your table and your data##Breaking Changes ####v.1.2.0
sort-order
option type was changed from Object
to Array
to support multi-sort
, therefore it should be declared as array. #36
<vuetable
//...
:sort-order="[{ field: 'name', direction: 'asc' }]"
></vuetable>
##Live Demo
vuetable
?vuetable
is a Vue.js component that will automatically request (JSON) data
from the server and display them nicely in html table with swappable/extensible
pagination sub-component. You can also add buttons to each row and hook an event
to it
Please note that all the examples show in here are styling using Semantic UI CSS Framework, but
vuetable
should be able to work with any CSS framwork including Twitter's Bootstrap. Please read through and see more info below.
You do this:
<div id="app" class="ui vertical stripe segment">
<div class="ui container">
<div id="content" class="ui basic segment">
<h3 class="ui header">List of Users</h3>
<vuetable
api-url="http://example.app:8000/api/users"
table-wrapper="#content"
:fields="columns"
:item-actions="itemActions"
></vuetable>
</div>
</div>
</div>
<script>
new Vue({
el: '#app',
data: {
columns: [
'name',
'nickname',
'email',
'birthdate',
'gender',
'__actions'
],
itemActions: [
{ name: 'view-item', label: '', icon: 'zoom icon', class: 'ui teal button' },
{ name: 'edit-item', label: '', icon: 'edit icon', class: 'ui orange button'},
{ name: 'delete-item', label: '', icon: 'delete icon', class: 'ui red button' }
]
},
methods: {
viewProfile: function(id) {
console.log('view profile with id:', id)
}
},
events: {
'vuetable:action': function(action, data) {
console.log('vuetable:action', action, data)
if (action == 'view-item') {
this.viewProfile(data.id)
}
},
'vuetable:load-error': function(response) {
console.log('Load Error: ', response)
}
}
})
</script>
And you get this!
Since I'm mainly using Semantic UI as my default CSS Framework, all the css
styles in vuetable
are based on Semantic UI. If you're using Twitter's Bootstrap
css framework, please see documentation in the Wiki pages.
$ bower install vuetable
$ npm install vuetable
Just import
or require
like so,
//
// firstly, require or import vue and vue-resource
//
var Vue = require('vue');
var VueResource = require('vue-resource');
Vue.use(VueResource);
//
// secondly, require or import Vuetable and optional VuetablePagination component
//
import Vuetable from 'vuetable/src/components/Vuetable.vue';
import VuetablePagination from 'vuetable/src/components/VuetablePagination.vue';
import VuetablePaginationDropdown from 'vuetable/src/components/VuetablePaginationDropdown.vue';
import VuetablePaginationBootstrap from 'vuetable/src/components/VuetablePaginationBootstrap.vue';
//
// thirdly, register components to Vue
//
Vue.component('vuetable', Vuetable);
Vue.component('vuetable-pagination', VuetablePagination)
Vue.component('vuetable-pagination-dropdown', VuetablePaginationDropdown)
Vue.component('vuetable-pagination-bootstrap', VuetablePaginationBootstrap)
You can combine the second and third steps into one if you like.
You need to explicitly register the pagination components using Vue.component()
(instead of just declaring them through the components:
section); otherwise, the pagination component will not work or swappable or extensible. I guess this is because it is embedded inside vuetable
component.
Just import the vue-table.js
after vue.js
and vue-resource.js
library in your page like so.
<script src="js/vue.js"></script>
<script src="js/vue-resource.js"></script>
<script src="js/vue-table.js"></script>
Then, reference the vuetable via <vuetable>
tag as following
<div id="app">
<vuetable
api-url="/api/users"
:fields="columns"
></vuetable>
</div>
<script>
new Vue({
el: '#app',
columns: [
'firstname',
'lastname',
'nickname',
'birthdate',
'group.name_en',
'gender',
'last_login',
'__actions'
]
})
</script>
api-url
is the url of the api that vuetable
should request data from.
The returned data must be in the form of JSON formatted with at least the number of fields
defined in fields
property.fields
is the fields mapping that will be used to display data in the table.
You can provide only the name of the fields to be used. But if you would like to get
the true power of vuetable
, you must provide some more information.
Please see Field Definition
section for more detail.For more detail, please see documentation in the Wiki pages.
Run npm install
Then make sure, you have installed browserify:
# npm install browserify -g
You might need root access for running the above command.
Then you can simply run the build script included in the root folder:
$ ./build.sh
This will compile the vue components in the src
directory to one file in the dist
folder.
You might want to get a minified version, in this case run this:
$ ./build.sh production
For developement it's useful when it's not needed to recompile manually each time you make a change. If you want this convenience first install watchify globally:
# npm install watchify -g
then run
$ ./build.sh watch
Now each time you make a change, the source will be recompiled automatically.
As I use Chrome almost exclusively, it is gaurantee to work on this browser and it SHOULD also work for other WebKit based browsers as well. But I can't really gaurantee that since I don't use them regularly.
However, vuetable
will NOT WORK on Internet Explorer (even IE11) due to the use of <template>
tag inside <table>
according to this. In order to make it work with CSS framework table styling, I have to preserve the use of <table>
and <template>
tag inside it.
It seems to work just fine in Microsoft Edge though. Anyway, if you find that it does not work on any other browser, you can let me know by posting in the Issues. Or if you are able to make it work on those browser, please let me know or create a pull request.
Any contribution to the code (via pull request would be nice) or any part of the documentation (the Wiki always need some love and care) and any idea and/or suggestion are very welcome.
However, please do not feel bad if your pull requests or contributions do not get merged or implemented into vuetable
.
Your contributions can, not only help make vuetable
better, but also push it away from what I intend to use it for. I just hope that you find it useful for your use or learn something useful from its source code. But remember, you can always fork it to make it work the way you want.
vuetable
is open-sourced software licensed under the MIT license.
FAQs
vue.js table component that will automatically request JSON data from server and display them nicely in HTML table with swap-able/extensible pagination component. This is the django-restframework backend modification version.
We found that vuetable-django demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.
Research
Security News
Lazarus-linked threat actors expand their npm malware campaign with new RAT loaders, hex obfuscation, and over 5,600 downloads across 11 packages.
Security News
Safari 18.4 adds support for Iterator Helpers and two other TC39 JavaScript features, bringing full cross-browser coverage to key parts of the ECMAScript spec.