VueJs dynamic table rows – Add and Delete Rows dynamically using VueJs

VueJs dynamic table rows – Add and Delete Rows dynamically using VueJs

Today, We want to share with you VueJs dynamic table rows – Add and Delete Rows dynamically using VueJs.
In this post we will show you VueJs dynamic table rows – Add and Delete Rows dynamically using VueJs, hear for VueJs dynamic table rows – Add and Delete Rows dynamically using VueJs we will give you demo and example for implement.
In this post, we will learn about VueJs dynamic table rows – Add and Delete Rows dynamically using VueJs with an example.

This Post covers the following topics Like as…

– Create a Table Row dynamically inside the table from inside form data using vuejs
– Add a Action Simple Delete button to the Deleted table Row using vuejs
– Simple Ability to Add the dynamically generated table Row using vuejs

READ :  Vue js First Application Example with vue mvc

in this Example will you show Creating dynamic table using Vue.js javscript Frameworks

Inclide Vuejs Libs

<a href="http://2.1.3/jquery.min.js">http://2.1.3/jquery.min.js</a>
<a href="http://openexchangerates.github.io/accounting.js/accounting.min.js">http://openexchangerates.github.io/accounting.js/accounting.min.js</a>
<a href="http://Sortable/Sortable.js">http://Sortable/Sortable.js</a>
<a href="http://vue/1.0.28/vue.min.js">http://vue/1.0.28/vue.min.js</a>
<a href="http://js/index.js">http://js/index.js</a>

List Of VueJs dynamic table functionality

-One simple here vuetable tag
-VueJs dynamic table rows
-VueJs dynamic table columns
-add and delete rows dynamically using VueJs
-VueJs dynamic table header,VueJs dynamic table from json
-VueJs datatables dynamic columns
-VueJs json table

index.html

	<h1>How to add new rows dynamically Vue.js</h1>
<div class="panel-body" id="app">
	<h2>Creating Dynamic Tables with Vue.js</h2>
	<table class="table table-hover">
		<thead>
		<tr>
			<th>Sr No.</th>
			<th>Product Description</th>
			<th>Product Qty</th>
			<th>Product Price</th>
			<th>Product Tax</th>
			<th>Total</th>
			<th>Action</th>
		</tr>
		</thead>
		<tbody>
		<tr>
			<td>
				{{ $index +1 }}
			</td>
			<td>
				
			</td>
			<td>
				
			</td>
			<td>
				
			</td>
			<td>
				
					0%
					10%
					20%
				
			</td>
			<td>
				
				
			</td>
			<td>
				<button class="btn btn-primary btn-xs">Add Row</button>
				<button class="btn btn-danger btn-xs">remove Row</button>
			</td>
		</tr>
		</tbody>
		<tfoot>

		<tr>
			<td colspan="5" class="text-right">TAX</td>
			<td colspan="1" class="text-right">{{ taxtotal | DisplayCustomCurr }}</td>
			<td></td>
		</tr>
		<tr>
			<td colspan="5" class="text-right">TOTAL</td>
			<td colspan="1" class="text-right">{{ total | DisplayCustomCurr }}</td>
			<td></td>
		</tr>
		<tr>
			<td colspan="5" class="text-right">GET-DELIVERY</td>
			<td colspan="1" class="text-right"></td>
			<td></td>
		</tr>
		<tr>
			<td colspan="5" class="text-right"><strong>GRANDTOTAL</strong></td>
			<td colspan="1" class="text-right"><strong>{{ grandtotal = total + getdelivery | DisplayCustomCurr }}</strong></td>
			<td></td>
		</tr>
		</tfoot>
	</table>
	<br />
	<a href="https://infinityknow.com" target="_blank" title="Download,free download,steps download,download quickly,easy download,steps download,all download" class="download">Example</a>
	<button>ADD Data</button>
	<pre>{{ $data | json }}</pre>
</div>

index.js

Vue.filter('DisplayCustomCurr', {
    read: function (val) {
        if (val > 0) {
            return accounting.formatMoney(val, "$", 2, ".", ",");
        }
    },
    write: function (val, oldVal) {
        return accounting.unformat(val, ",");
    }
});

Vue.directive('sortable', {
    twoWay: true,
    deep: true,
    bind: function () {
        var that = this;

        var options = {
            draggable: Object.keys(this.modifiers)[0]
        };
        this.sortable = Sortable.create(this.el, options);
        this.sortable.option("onUpdate", function (e) {            
            that.value.splice(e.newIndex, 0, that.value.splice(e.oldIndex, 1)[0]);
        });

        this.onUpdate = function(value) {            
            that.value = value;
        }
    },
    update: function (value) {        
        this.onUpdate(value);
    }
});

var vm = new Vue({
    el: '#app',
    data: {
        products: [
            {qty: 15, description: "Pakainfo.com", price: 25.20, tax: 15},
            {qty: 12, description: "live24u else", price: 33.20, tax: 20},
        ],
        total: 0,
        grandtotal: 0,
        taxtotal: 0,
        getdelivery: 41
    },
    computed: {
        total: function () {
            var t = 0;
            $.each(this.products, function (i, e) {
                t += accounting.unformat(e.total, ",");
            });
            return t;
        },
        taxtotal: function () {
            var tt = 0;
            $.each(this.products, function (i, e) {
                tt += accounting.unformat(e.tax_amount, ",");
            });
            return tt;
        }
    },
    methods: {
        addlived: function (index) {
            try {
                this.products.splice(index + 1, 0, {});
            } catch(e)
            {
                console.log(e);
            }
        },
        removelived: function (index) {
            this.products.splice(index, 1);
        },
        getData: function () {
            $.ajax({
                context: this,
                type: "POST",
                data: {
                    products: this.products,
                    total: this.total,
                    getdelivery: this.getdelivery,
                    taxtotal: this.taxtotal,
                    grandtotal: this.grandtotal,
                },
                url: "/api/data"
            });
        }
    }
});

Example

READ :  Angular ng-repeat reverse Example - reverse filter

Example

We hope you get an idea about VueJs dynamic table rows – Add and Delete Rows dynamically using VueJs
We would like to have feedback on my Information blog .
Your valuable any feedback, Good question, Inspirational Quotes, or Motivational comments about this article are always welcome.
If you liked this post, Please don’t forget to share this as Well as Like FaceBook Page.

We hope This Post can help you…….Good Luck!.

Leave a Reply

Your email address will not be published. Required fields are marked *