包详细信息

vuetable-2

ratiw52.1kMIT1.7.5

Datatable component for Vue 2.x

vue, component, table, datatable

自述文件

npm npm npm

Vuetable-2 - data table simplify!

Vuetable-2 works with Vue 2.x, vuetable is for Vue 1.x

If you're looking for the version that's working with Vue 1.x, please go to vuetable repo.


Documentation and Tutorial

Documentation is still under development, but you can view it at https://ratiw.github.io/vuetable-2. Thanks to @cristijora for the help.

Meanwhile, check out

  • the Tutorial with follow-along project here. It should be enough to get you started.

  • Sample project using Vuetable-2 with Laravel 5.4 and Laravel-Mix

If you've been using Vuetable for Vue 1.x before, checkout what's changed for info on changes from Vuetable for Vue 1.x and the upgrade guide on how you could upgrade from Vuetable for Vue 1.x.

You can now make use of Vue's scoped slot using the new __slot special field, thanks to @sjmarve. That means you are able to define action buttons per instance of a data table without depending on a globally defined component.

Use scoped slot in parent when defining the actions Vue Doc for scopped Slots

e.g.

<template slot="actions" scope="props">
    <div class="table-button-container">
        <button class="btn btn-default" @click="onClick('edit-item', props.rowData)"><i class="fa fa-edit"></i> View</button>&nbsp;&nbsp;
        <button class="btn btn-danger" @click="onClick('delete-item', props.rowData)"><i class="fa fa-remove"></i> Edit</button>&nbsp;&nbsp;
    </div>
</template>

the onClick function can now be defined in the parent and the parent has Access to rowData and rowIndex via props. :)

The original functionality still works

Breaking Changes

v1.6.0

  • The icons prop of VuetablePagination is now moved into the css prop object. See this codepen.

Example Code

  • Clone the project
  • Go into the cloned directory
  • npm install
  • npm run dev
  • Open browser to http://localhost:8080

Usage

NPM

npm install vuetable-2 --save-dev

Javascript via CDN

Thanks to @cristijora for providing helps on this.

// vuetable-2 dependencies
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.2.6/vue.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.16.1/axios.min.js"></script>
// vuetable-2
<script src="https://unpkg.com/vuetable-2@1.6.0"></script>
Vue.use(Vuetable)

This is demonstrated in this jsfiddle.

The .use from above will register all the components globally.

function install(Vue){
  Vue.component("vuetable", Vuetable);
  Vue.component("vuetable-pagination", VueTablePagination);
  Vue.component("vuetable-pagination-dropdown", VueTablePaginationDropDown);
  Vue.component("vuetable-pagination-info", VueTablePaginationInfo);
}

Also you have the ability to access certain components if you need them:

VueTable: VueTable.default/VueTable.VueTable,
VueTablePagination: VueTable.VueTablePagination,
VueTablePaginationInfo: VueTable.VueTablePaginationInfo,
VueTablePaginationDropdown: VueTable.VueTablePaginationDropdown

Contributions

Any contribution to the code (via pull request would be nice) or any part of the documentation and any idea and/or suggestion are very welcome.

Note For any bug fix, the PR should be forked from the master branch. And for any suggestion or additional feature, the PR should be forked from the develop branch, where it can be integrated and rolled out in the next release.

If you are not sure, please ask by openning a new issue.

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.

License

Vuetable is open-sourced software licensed under the MIT license.

更新日志

What's Changed

  • vuetable-pagination is no longer part of vuetable by default.
    • better customization
    • cleaner implementation
    • easy to setup
      • listen to vuetable:pagination-data event on vuetable-table> component to wire the pagination data to vuetable-pagination component.
      • listen to vuetable-pagination:change-page event on designated vuetable-pagination component to wire the page changing request to vuetable-table
  • Due to deprecations of $broadcast and $dispatch in Vue 2.0, all of the listening events where you used to be able to sent vuetable to perform task, e.g. refresh() are no longer existed. Please check documentation. You are now required to use ref to directly refer to the vuetable components to directly use its API for certain functionality.
    • Available events
      • vuetable:loading
      • vuetable:loaded
      • vuetable:load-success
      • vuetable:load-error
      • vuetable:pagination-data
      • vuetable:row-changed
      • vuetable:row-clicked
      • vuetable:detail-row-clicked
      • vuetable:cell-clicked
      • vuetable:cell-dblclicked
      • vuetable:checkbox-toggled
    • No longer available
      • vuetable:reload -- directly call reload() method instead
      • vuetable:refresh -- directly call refresh() method instead
      • vuetable:goto-page -- directly call changePage() method instead
      • vuetable-pagination:change-page -- no real use now
      • vuetable:action -- no longer use as __actions is removed.
  • __actions special field was removed in favor of __component. See example.
  • appendParams prop type changes from Array to Object to reflect the change in updating vue-resource to version 1.0 (Breaking Change)
  • vuetable should now work with IE, thanks to template compilation to virtual DOM.
  • Removed properties
    • wrapper-class
    • table-wrapper
    • show-pagination
    • pagination-component
    • pagination-component-class
    • pagination-class
    • selected-to
    • http-data -- vue-resource API change, use http-options instead
  • Moved properties
    • The following are properties related to CSS, which are now moved inside css prop.
      • tableClass
      • loadingClass
      • ascendingIcon
      • descendingIcon
      • detailRowClass
    • The following pagination info related properties are now moved into its own component PaginationInfo.
      • pagination-info-class
      • pagination-info-template
      • pagination-info-no-data-template
  • vuetable:load-success event is now fired right after the requested data has been successfully retrieved. This is logically how it should be. Previously, it was fired after the tableData and tablePagination have been set.

New Features

  • Data transformation via transform method.