Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transform method doesn't get triggered #162

Open
ccramiro opened this issue Jun 29, 2017 · 1 comment
Open

Transform method doesn't get triggered #162

ccramiro opened this issue Jun 29, 2017 · 1 comment

Comments

@ccramiro
Copy link

Hi there,

I am using Java as backed, pagination is handled by Spring, so data needs to be transformed to be displayed properly in the table. Following instructions here, I added a transform method to translate the data I receive to the data vuetable understand. As far as I understand, the transform method should be triggered to build the table but nothing happens and I get an error because the pagination-path is not found. The code is as follows:

  <div class="ui container">
      <div id="content" class="ui basic segment">
          <h3 class="ui header">Playes</h3>
          <vuetable
              api-url="/api/players"
              table-wrapper="#content"
              data-path="mydata"
              pagination-path="pagination"
              :fields="columns"
          ></vuetable>
      </div>
  </div>
new Vue({
  el: '#app',
  data: {
    columns: ['name', 'games', 'minsPlayed' ]
  },
  methods: {
    transform: function(data) {
      console.log("DATA " + JSON.stringify(data));

      var transformed = {}

      transformed.pagination = {
        total: data.totalElements,
        per_page: data.size,
        current_page: data.number,
        last_page: data.totalPages,
        from: data.from,
        to: data.to
      }
      transformed.mydata = []

      for (var i=0; i < data.length; i++) {
        transformed.data.push({
          player.name: data[i].player.name,
          games: data[i].games,
          minsPlayed: data[i].minsPlayed
        })
      }
    }
  }
})

vue.js, resource and vue-table are added from CDN

And the error I get:

vuetable: pagination-path "pagination" not found. It looks like the data returned from the sever does not have pagination information or you may have set it incorrectly.
(anonymous) @ vue-table.min.js:1

@ratiw
Copy link
Owner

ratiw commented Jul 1, 2017

The transform function should return the transformed object. The example in the wiki is also missing this. Sorry for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants