Giter VIP home page Giter VIP logo

Comments (4)

matfish2 avatar matfish2 commented on May 31, 2024

You need to register the component GLOBALLY using Vue.component().
Local registration is not inherited by child components.

from vue-tables-2.

forddyce avatar forddyce commented on May 31, 2024

Ok so I was able to make something work with this:

import Vue from 'vue'

var editlink = Vue.extend({
  props: ['id'],
  methods: {
    getItem () {
      console.log(this.id)
    }
  },
  render: function (e) {
    return e('button', {
      attrs: {
        class: 'btn btn-primary btn-sm'
      },
      on: {
        click: this.getItem
      }
    }, [ e('i', {
      attrs: {
        class: 'glyphicon glyphicon-edit'
      }
    })])
  }
})

Vue.component('edit-link', editlink)

var tableColumns = ['name', 'stock', 'sku', 'price', 'created_at']
var options = {
  pagination: {
    dropdown: true,
    chunk: 10
  },
  filterByColumn: true,
  texts: {
    filter: 'Search:'
  },
  datepickerOptions: {
    showDropdowns: true
  },
  headings: {
    name: 'Nama',
    stock: 'Stok',
    sku: 'SKU',
    price: 'Harga',
    created_at: 'Dibuat Pada',
    edit: 'Edit',
    delete: 'Delete'
  },
  templates: {
    edit: function (h, row) {
      return <edit-link id={row.id}></edit-link>
    },
    delete: function (h, row) {
      return <a href="javascript:void(0);" class="btn btn-danger btn-sm"><i class="glyphicon glyphicon-erase"></i></a>
    }
  }
}

export default {
  name: 'ItemList',
  data: function () {
    return {
      options: options,
      columns: tableColumns
    }
  }
}

But of course in the app there won't be only 1 table, there will be 1 for each modules later. Do I really have to make new components for every table? Won't that make the app slower/bigger or if somehow I had the same component name it will break?

from vue-tables-2.

matfish2 avatar matfish2 commented on May 31, 2024

A. This is the way vue is designed. Take it up to the management if you think it should be changed.
B. Why make new components? Reuse the same one. You will have one edit-link component which is reusable across all tables.

from vue-tables-2.

forddyce avatar forddyce commented on May 31, 2024

Thank you, I forgot I can reuse it, sorry for the trouble, I'm still learning it.

from vue-tables-2.

Related Issues (20)

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.