0

I'm working with VUE and boostrap-table works very well!

In my component I have:

<BootstrapTable :columns="table.columns" :data="table.data" :options="table.options"></BootstrapTable>`

Then axios populated the table. It works good.

I'm getting issues updating the table with calculated data received by axios. And I was wondering if there is "a best practices" for this. Basically, I need to create a custom link in first column using the id received by axios, but I would like to use the vue router.

When I got the axios data I create a custom array newData and then I update the table with:

this.$nextTick(function () { this.table.data = newData });

The array has a custom link like

link: '<a v-bind:href="club/'+team.id+'">'+team.team+'</a>',

or

 link: "<router-link :to=\"{'name': 'team',\'params\': { 'id':"+ team.id+" }}\">"+ team.team+"</router-link>",

But this is paste as plain text and not rendered.

At the moment I'm using

link: "<a href='/club/" + team.id + "'>" + team.team + "</a>",

It works but, obviously, it reloads the whole page instead of using the VUE router...

Any suggestion? The vue render() function could be help? How?

1 Answer 1

0

Fixed using events in the column. This is the column having calculated link:

                  columns:
                        [
                       {...},
                       {
                        field: 'match',
                        title: 'Match',
                        formatter (value, row) {
                            return `<a href="/matches/${row.pos}">${value}</a>`
                        },
                        events: {
                            'click a': (e, value, row, index) => {
                               e.preventDefault();
                                this.$router.push(`/matches/${row.pos}`)
                                }
                           }
                         },
                        {...}]

Here the workaround.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.