Giter Club home page Giter Club logo

vue-smart-table's Introduction

Not compatible with Vue 2.0, looking for a maintainer for this project.

vue-smart-table

Join the chat at https://gitter.im/gurghet/vue-smart-table

npm

Vue Smart Table is a simple but powerful table framework. Every column is a component.

Usage

Basically you write this

<smart-table
    :auto-load="true"
    body-path="results"
    id-col="id.value"
    endpoint="http://api.randomuser.me/?results=20"
    :header="[
    {key: 'name.first', label: 'name'},
    {key: 'name.last', label: 'surname'},
    {key: 'gender'},
    {key: 'phone+cell', label: 'contacts'},
    {key: 'picture.thumbnail', label: 'avatar'}
    {key: 'nat', label: 'nationality'}
    ]"
    :order-by="['name.first', 'name.last']"
    >
   <src2img col="picture.thumbnail"></src2img><!-- renders pictures -->
   <contacts col="phone+cell"></contacts><!-- custom formatting -->
   <nationality col="nat"></nationality><!-- queries a remote server for country code to country name conversion -->
   <fontawesome col="gender"></fontawesome><!-- font awesome! -->
  </smart-table>

and you get this

vue smart table

Demo

Installation

If you use Webpack/Browserify

npm install vue-smart-table --save

In your app then you write:

import SmartTable from "vue-smart-table"
Vue.component('smart-table', SmartTable)

Alternatively you can add it to your components options

import SmartTable from "vue-smart-table"
// ...
components: {
    'smart-table': SmartTable
  }
// ...

In Webpack you will have to transpile some .js files inside the vue-smart-table, since the node_modules directory it’s excluded by default in the vue-cli template, remember to enable it. This means that if your js loader is like this:

{
  test: /\.js$/,
  loader: 'babel',
  include: projectRoot,
  exclude: /node_modules/ // <-- this needs to be changed
}

You will have to spare the folder node_modules/vue-smart-table/src/components from exclusion. Just turn the exclude property to:

exclude: /node_modules(?!\/vue-smart-table\/src\/components)/

If you use the <script> tag inside your page

This is ideal if you are using Smart Table as a drop-in component in a bigger project that is not based on Vue.js

The vue-smart-table.js does not contain vue and vue-resource dependencies, those will also need to be on the page.

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue-smart-table/2.5.0/vue-smart-table.js"></script>
<!-- or -->
<script src="https://unpkg.com/[email protected]/dist/static/vue-smart-table.js"></script>

That’s it! The component will register itself! Remember do add a min.js when going in production.


After that you can freely use it in your templates:

<smart-table :body="[{hello:'world'}]"></smart-table>

Smart Table Tutorial in under 20 seconds

Documentation

You will find documentation at the wiki page (although there is no versioning there, so heads up)

Documentation

For more information visit: http://forum.vuejs.org/topic/4140/vue-smart-table

The format of the body prop is like the following:

[ { _id: 3 , name: 'John'  , surname: 'Smith' },
  { _id: 92, name: 'Fulano', surname: 'Perro' } ]

Pokédex table

Smart Table for pokeapi.co ____________________________LIVE DEMO

Contribute

# install dependencies
npm install

# serve demo app with hot reload at localhost:8080
npm run dev

# build standalone with minification
npm run build

# run unit tests
# always run unit tests! D:<
npm run ~unit
# for the body parsing run
npm run ~funit

Roadmap

  • Bootsrap/Semantic compatibility
  • Derived columns
  • Sorting
    • Client side
    • Server side
  • Pagination
    • Client side
    • Server side
  • Inline editing
    • Inline adding
    • Inline validation
  • Drag row to reorder
  • Filtering
    • Client side
    • Server side

Similar Components

Here is a list of similar components that also display a table:

Changelog

2.5.0

  • Complete engine rewrite!
    • Core logic was ~100 lines, now only ~15
    • Such maintainance
    • Many development speed
    • wow!
  • [Feature] Client filtering is now supported through the filter event

2.4.3

  • [Fix] Polyfill for find added for Chrome for Android

2.4.2

  • [Fix] As a workaround for Safari, use explicitly CSS polyfill

2.4.1

  • [Fix] Added polyfill for CSS.escape
  • [Fix] Removed instances of HTMLNodelist.forEach

2.4.0

  • [Feature] Inline edit capabilities with more advanced components
  • Breaking change: format of the header prop is changed (:header="[{key: 'key1', label: 'label'}, {key: 'keyEqualsToLabel'}]"
  • Breaking change: body-field => body-path
  • Bootstrap/Semantic compatibility

2.3.1

  • [Fix] Shows _id column if explicitly set in the header

2.3.0

  • click column headers to order by that column

2.2.1

  • again forgot about the dist files -.-

2.2.0

  • can set body-field to empty string if data is already in an array

2.1.1

  • forgot to rebuild the dist files -.-

2.1.0

  • derived columns (:header="{'home+office+mobile':'contacts'}")

2.0.0

  • completely new body format (see docs)
  • auto loading data on startup using the "auto-load" prop
  • header can read from nested attributes with dot notation (eg. "name.last")
  • ids can now include letters, some signs (._-) and can be null
  • body and id fields can be changed through "body-field" and "id-col" props

1.0.5

  • stains the global scope with SmartTable constructor

1.0.4

Working on break dependencies on other modules

  • build now yields only two files
  • external dependencies now needs to be available in global namespace
    • Ramda
    • jQuery
    • Vue
    • VueResource

vue-smart-table's People

Contributors

adonm avatar bryant1410 avatar gitter-badger avatar gurghet avatar npmcdn-to-unpkg-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-smart-table's Issues

Customizable PUT call for inline editing

Probably via prop of the plain-text or some other prop of the Smart Table.

The guiding principle should be maximum customizability but with the costraint of using one of the already used ways for customization. No new information sohuld be required to learn how to do a call.

The first thing to do should be to have a list of the most common ways to call a RESTful interface and verify that is a one-liner with at least 80% of them.

Is there a way to use a dropdown component inside of the smart-table?

Hello Andrea!

I wanna use dropdown component (like this for example https://github.com/JosephusPaye/Keen-UI/blob/master/src/UiMenu.vue it gets an array for options) inside of the table for each entry. And option might be 'View', 'Delete' etc. Its works fine when you need just static option, but in my case I need unique id for each entry in the table.

<smart-table
    body="dataTable"
    >
   <ui-menu :list="$parent.dataTable.dropdown"></ui-menu>
  </smart-table>
        var dataTable = [
                {
                    img: '',
                    name: '',
                    region: '',
                    dropdown: [
                        {
                            id: '',
                            text: '',
                            url: ''
                        }
                    ]
                },
            {% endfor %}
        ];

So it doesn't works. Only works if I type something like <ui-menu :list="$parent.dataTable[0].dropdown"></ui-menu> but of course it isn't solution because the id will the same for all entries. But I want to itterate them.

Please, provide some example of can I do that maybe with another dropdown component or even with basic select. Thanks you so much!

Columns with spaces inside the key

Issue found in #2

Problem

Columns in spaces are interpreted like separate classes

Solution

Pre-process column names to convert spaces to dashes -

Doesn't work in IE11

Hi, I want to support IE11 but it seems like this component doesn't. I got this error in the console of IE11

Object doesn't support property or method 'find'

var row = father.processedSmartBody.find(byId(id));

I didn't find a solution. If you know how to fix it, share please.

Doesn't work in Safari and FF

I test my pages which contain smart-table component and I found that they doesn't display in Safari (last version) and Firefox. One error display in console of the browsers

TypeError: CSS.escape is not a function. (In 'CSS.escape(col)', 'CSS.escape' is undefined)

It can support vue2.*?

I use webpack and vue-cli to init my project, then install packages,and npm run dev,but,it has two mistakes,I don not understand.

Uncaught TypeError: Cannot read property 'get' of undefined

<smart-table
    :auto-load="true"
    body-path="results"
    id-col="id.value"
    endpoint="http://api.randomuser.me/?results=20"
    :order-by="['name.first', 'name.last']"

    ></smart-table>

Getting this stacktrace when using any value in endpoint. Above snippet is copy pasted from readme.

Uncaught TypeError: Cannot read property 'get' of undefined
refresh @ SmartTable.vue?c608:409
(anonymous function) @ vue.common.js?e881:216
compiled @ SmartTable.vue?c608:345
Vue._callHook @ vue.common.js?e881:8235
Vue._compile @ vue.common.js?e881:8628
Vue.$mount @ vue.common.js?e881:9446
Vue._init @ vue.common.js?e881:2468
Vue._init @ vue-router.js?e71f:1756
SmartTable @ VM47638:2

Using Vue 1.0.26, installed SmartTable with NPM and using webpack.

Vue2 Compatibility

Is this component incompatible with Vue2?

ERROR in ./~/vue-loader/lib/template-compiler.js?id=data-v-489a263a!./~/vue-loader/lib/selector.js?type=template&index=0!./~/vue-smart-table/src/components/SmartTable.vue
template syntax error class="col-{{col.key}} col-cell {{canOrderBy(col.key) ? 'ord' : ''}} {{orderClass(col.key)}}":
Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead. For example, instead of <div class="{{ val }}">, use <div :class="val">.

ERROR in ./~/vue-loader/lib/template-compiler.js?id=data-v-3e309329!./~/vue-loader/lib/selector.js?type=template&index=0!./~/vue-smart-table/src/components/PlainText.vue
template syntax error - invalid expression: {{{processedText}}}

Babel language tag

The dependency for making http requests or something hasn't installed when I called meteor npm install, but now it's complaining that I also don't have handler for babel tag.

When the body gets updated externally, the filters get reset

When the body changes the pBody is updated but this doesn't trigger the re-application of filters and there is a chance that this has to be done for ordering to.

The solution is to trigger filtering and ordering before rendering the table.

Pagination

Hi Andrea,

How to create a pagination if I get data from array? No ajax or jSON.

Can't pass array from the table to component

Hello @gurghet!

I have a component (show-menu) which I put in <smart-table>. And menu component inside of show-menu component.

show-menu component html:

<menu :options="menuOptions"></menu>

show-menu component js:

    props: {
        menuOptions: {
            type: Array,
            required: true,
            default() {
                return [];
            }
        }    
    },

use smart-table on the page:

<smart-table
    :body="body"
    :order-by="['first', 'second', 'third']"
    >
    <show-menu :menu-options="menuOptions" col="third"></show-menu>
</smart-table>

inside of script tag:
var menuOptions = [
    {
        id: 'test',
        text: 'test'
    }, {
        id: 'test1',
        text: 'test1'
    }
];

and in js file of the page:
data: {
    menuOptions: menuOptions
}

It doesnt works. No error, just empty menu list. But it works perfect outside of smart-table, for example if I move this line of code outside of smart-table:

<show-menu :menu-options="menuOptions" col="third"></show-menu>

What I do wrong?

Browserify error

As soon as i try to require it, i get this:

Browserify Failed!: Unexpected token

/public/node_modules/vue-smart-table/src/components/SmartTable.vue:1
<template>
^
ParseError: Unexpected token

Interpolation inside attributes has been removed

When I try to run the Hello World example from the readme file, I get this error in the console:

[Vue warn]: class="col-{{col.key}} col-cell {{canOrderBy(col.key) ? 'ord' : ''}} {{orderClass(col.key)}}": Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead. For example, instead of <div class="{{ val }}">, use <div :class="val">.

My package.json has:

"vue": "^2.0.5",
"vue-router": "^2.0.1",
"vue-smart-table": "^2.6.0-beta5"

Any ideas on how to avoid this error and run the Hello World example? Thanks.

Add filtering scope

Sometimes you have more than one Smart Table. We should add an optional field in the filter event message that specifies that the table to be filtered to have some id. The v-ref could be used for this purpose.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.