matfish2 / vue-tables-2

Vue.js 2 grid components
https://matanya.gitbook.io/vue-tables-2/
GNU General Public License v3.0
1.53k stars 305 forks source link

v-server-table - example please #10

Closed ab-su-rd closed 8 years ago

ab-su-rd commented 8 years ago

could you give an example for wrapping the v-server-table with a v-if please?

i am finding that putting the v-if directive with false never triggers the network call to fetch data, and setting it to true triggers the loading event, but vue-tables errors out with Cannot read property 'get' of undefined not seeing a network call in either case.

my code

                <div id="assets-vue"
                     v-if="!loading"
                >
                    <v-server-table
                            url="/people"
                            :columns="columns"
                            :options="options"
                            name="assets-table"
                    >
                    </v-server-table>
                </div>

btw, i'm using the library after compiling it with browserify sections from package.json:

    "build-vue-tables": "browserify node_modules/vue-tables-2/index.js --s VueTables | uglifyjs -c > public/js/vue-tables.js"
  "browserify": {
    "transform": [
      "babelify",
      {
        "presets": [
          "es2015"
        ],
        "plugins": [
          "transform-vue-jsx"
        ]
      }
    ]
  },

i also had to set .babelrc, for some reason

{
    "plugins": ["transform-vue-jsx"],
    "presets": ["es2015"]
}
matfish2 commented 8 years ago

Not sure. Need to test this scenario. In the meantime you can probably use v-show instead.

ab-su-rd commented 8 years ago

v-show has the same behaviour, i'm afraid.

same behaviour in the sense that, i'm seeing the same error as with truthy v-if

matfish2 commented 8 years ago

Ok. I've tested both v-if and v-show and was unable to reproduce. I believe your issue has nothing to do with those directives.

The error Cannot read property 'get' of undefined Probably stems from the fact that you didn't include vue-resource and so this.$http is undefined

ab-su-rd commented 8 years ago

Indeed!

I was missing vue-resource

Thank you very much for pointing it out and for what you are doing here!