how to take sum and display it in vuetify datatable

时间:2018-02-03 11:01:42

标签: vue.js vuejs2 vue-component vuetify.js

Hi friends I am new to Vue. Pleas help me I am using vue2, vuetify 0.17 and datatable component. My problem is I want to take sum of area, floor columns from the data. I calculated the running total using map function and stored it in total{'area' : 100, 'floor':7}. Now in footer I want to display the totals.

<v-data-table
v-bind:headers="listData.columnProperty"
v-bind:items="listData.data"
v-bind:search="search"
:totals="{area : 100, flat : 7}" //is it allowed
>
<template slot="footer" slot-scope="totals">
Footer {{ totals}} {{ totals['area']}}
</template>

Please share any example which create a total and displays it into the footer. I need it badly.

1 个答案:

答案 0 :(得分:1)

你说你用totals计算了它,这样可行吗?

<template slot="footer">
    <td><strong>Sum</strong></td>
    <td class="text-xs-right">{{ totals.area }}</td>
    <td class="text-xs-right">{{ totals.flat }}</td> 
</template>

(不确定你的桌子看起来怎么样,但也许你明白了)