Vue-tables-2: is it possible to have a table as a childRow ?

Created on 24 Feb 2017  路  6Comments  路  Source: matfish2/vue-tables-2

I know I could mock my own html table, but is it possible to pass an instance of vue-table as a child row ?

So that when you click the toggler it expands and shows multiple table rows associated with each row of the parent table?

Most helpful comment

Nevermind, figured it out.

Here's what I did:

Create a child component:

Vue.component('child-table', {
    name: 'ChildRow',
    props: ['data'],
    template: '<v-client-table :data="childData" :columns="childColumns"></v-client-table>',
    data: function () {
        return {
            childColumns: ['foo', 'bazz', 'bar'],
            childData: [{
                foo: 'Col1',
                bazz: 'Col2',
                bar: 'Col3'
            }]
        };
    },
});

Create a parent table like normal. In the parent table, do:

data: { <yourcustomstuff> options: { <your custom options> childRow: 'child-table' } }

All 6 comments

I don't see why not. Add a property to each row which contains the data for the child table, and pass it as the data prop in the child row template.

Yep! I was just about to reply.. got it working after ~30m of trials.. and it's sooo awesome!!!!

@vesper8 I know this is old, but what did you do to accomplish this? If you're willing, a jsfiddle example would be aweseome.

Nevermind, figured it out.

Here's what I did:

Create a child component:

Vue.component('child-table', {
    name: 'ChildRow',
    props: ['data'],
    template: '<v-client-table :data="childData" :columns="childColumns"></v-client-table>',
    data: function () {
        return {
            childColumns: ['foo', 'bazz', 'bar'],
            childData: [{
                foo: 'Col1',
                bazz: 'Col2',
                bar: 'Col3'
            }]
        };
    },
});

Create a parent table like normal. In the parent table, do:

data: { <yourcustomstuff> options: { <your custom options> childRow: 'child-table' } }

there you go :) glad you figured it out

Hi,

Very interested in this solution to implement childRow; but I struggle to pass key parameter, as each sub-table data are built from the parent key. How can I link childtable to key of childRow ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

manrix picture manrix  路  3Comments

deryckoe picture deryckoe  路  3Comments

pmartelletti picture pmartelletti  路  4Comments

greenpdx picture greenpdx  路  4Comments

molerat619 picture molerat619  路  4Comments