ratiw / vue-table

data table simplify! -- 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 component.
MIT License
1.83k stars 303 forks source link

how to use templates properly? #75

Closed westwick closed 8 years ago

westwick commented 8 years ago

I'm trying to format a cell and nothing is working. The documentation seems to be a little vague here. I think I need to use the templates key on the options, right? It seems nothing I put in there causes any change on the table. I used the example right out of the docs but it's not working. Is there another example of how to do this somewhere?

Here is some of the relevant code:

<v-client-table :data="payments" :columns="columns" v-ref:table v-if="!loading"></v-client-table>

  var options = {
    compileTemplates: true,
    templates: {
      edit: "<a href={id}><i class='fa fa-edit'></i></a>"
    }
  }

then on the $vm:

    data () {
      return {
        payments: '',
        columns: ['created_at', 'amount'],
      }
    }

I have tried changing the templates key from edit to amount, thinking it would override the value in the amount column. I've also tried adding 'edit' to the columns array in the data. Seems neither one has any effect. Am I doing it wrong?

OliverGrimsley commented 8 years ago

In the vue component file, I had to delete everything in the tags and then do all my CSS in the regular css file. This is also a suggestion, to remove all style from the vue component. Because it gets loaded after the css, it controls and cannot be overridden. (In mine the table was way too big, way too much space, the actions aligned vertically in small grid areas etc)

westwick commented 8 years ago

hmm don't see what the css should have to do with anything. just trying to change the html using templates. I've tried for instance just creating a new key in the templates object, with the same name as one of my existing keys (thinking it would override it), or with a different name and adding that new name to the columns array. seems like the 2 most logical ways it would work based on the docs, but neither way works.

westwick commented 8 years ago

btw all I'm simply trying to do is use the {{ var | currency }} formatter in one of my cells, if anyone has any examples of that :)

westwick commented 8 years ago

wow just realized i'm on the wrong package x_x ... vue-table not vue-tables. ahh well maybe I will have to try your package if I can't get this other one working

ratiw commented 8 years ago

@westwick No problem. Got that all the time. :)