I have a table with data that I want to add a footer to in order to add up and display the Total of an int value in each row.
I have tried the following code.
I have the table as follows:
<b-table
id="myTable"
hover
striped
:items="myItems"
:fields="myFields"
show-empty
empty-text:"No items to display"
:foot-clone="true"
>
<template slot="FOOT_row" slot-scope="data">
<td>TOTAL<td>
<td/><td/>
<td><CurrencyFormatingComponent :Currency="data.Currency" :amount="this.CustomTotalFromData" class="pull-right"/></td>
</template>
</b-table>
My Vue data
myItems:[
{ Col1: "stuff", Col2: "otherStuff", Col3: "moreStuff", Col4: 12},
{ Col1: "stuffer", Col2: "otherStuffer", Col3: "moreStuffer", Col4: 10}
],
myFields:[ 'Name', 'NickName', 'FavoriteMovie', 'netWorth' ]
What I'm getting right now is just a footer that mirrors the header.
This is following the Bootstrap-Vue custom header documentation, but is very skimpy on details and gives no real information how to add truly custom information. I just want my template to show in the footer.
EDIT: Okay, so I did figure out the following. Still not what I want.
I realized that the way Bootstrap-Vue has this set up that you are cloning the header, and then you are replacing the data within each column.
so using this template:
<template slot="FOOT_Name" >
Don't render "Name".
</template>
It will replace the "Name" text in the footer for the "Name" column with the text I typed; Don't render"Name".
I'd Have to repeat this template for every slot that I want different. In my case, I have 6 columns so I'd have to have 5 blank templates in between the first to say Total
and the last to display that total in currency notation.
What I may need to do is just put in a <div/>
that mimics the footer I want and butt it up to the bottom of the table.
<div></div>
that contained the information I needed under the table ensuring there was no padding between the table and this div. This also allowed the element to be reactive to smaller screen sizes when bootstrap removes the header and footer, stacks all the columns in a row on top of one another with the added header label to each column data point. So a row ends up in a column view where each line is "Column1Label: Col1Data". Then my footer<div>
keeps the format I desire and i still at the bottom. – jeffcodes