Tagged: vue jquery datatables

Simple VueJS DataTables Example 0

Simple VueJS DataTables Example

Simple VueJS DataTables Example

In this Post We Will Explain About is Simple VueJS DataTables Example With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Vue 2.0 Data Table Component – Simple VueJS DataTables Example

In this post we will show you Best way to implement Datatable Pagination, Sorting and Search in Vuejs, hear for VueJS Datatable Pagination, Sorting and Searching Using Ajax with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Simple Example of Vuejs Datatable Module

In this Example(Simple VueJS DataTables),First of all Add or Inluce External Libs Like as a(jQuery, css etc..), and then create a simple index.php or index.html page.After that crate a simple javascript file like as a index.js or main.js, It is also add your web-application First Header Part to some priority set.After that Include your relevant CSS Class.

Include External Libs

https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js
https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.12/js/jquery.dataTables.min.js
https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.10/vue.min.js
https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.12/css/jquery.dataTables.min.css

index.html(Simple VueJS DataTables)

<div id="liveApp">
  <h3>Vue simple Datatable example</h3>
  Filter by Students List: <input v-model="liveSearch">
  <hr>
  <data-table :studs="filteredStudents"></data-table>
</div>

index.js(Simple VueJS DataTables)

Vue.component('data-table', {
  template: '<table></table>',
  props: ['studs'],
  data() {
    return {
      headers: [
        { title: 'ID' },
        { title: 'StudentName', class: 'some-special-class' },
        { title: 'Full Name' },
        { title: 'Mobile' },
        { title: 'Email' },
        { title: 'Website' }
      ],
      studRows: [] ,
      dtHandle: null
    }
  },
  watch: {
    studs(val, oldVal) {
      let vuemec = this;
      vuemec.studRows = [];
      val.forEach(function (studClass) {
        let studRow = [];
        studRow.push(studClass.id);
        studRow.push(studClass.studname);
        studRow.push(studClass.name);
        studRow.push(studClass.mobile);
        studRow.push('<a href="mailto://' + studClass.email + '">' + studClass.email + '</a>');
        studRow.push('<a href="http://' + studClass.web_id + '" target="_blank">' + studClass.web_id + '</a>');

        vuemec.studRows.push(studRow);
      });

      vuemec.dtHandle.clear();
      vuemec.dtHandle.studRows.add(vuemec.studRows);
      vuemec.dtHandle.draw();
    }
  },
  mounted() {
    let vuemec = this;
    vuemec.dtHandle = $(this.$el).DataTable({
     
      columns: vuemec.headers,
      data: vuemec.studRows,
      liveSearching: false,
      paging: false,
      info: false
    });
  }  
});

new Vue({
  el: '#liveApp',
  data: {
    studs: [],
    liveSearch: ''
  },
  computed: {
    filteredStudents: function () {
      let self = this
      let liveSearch = self.liveSearch.toLowerCase()
      return self.studs.filter(function (stud) {
        return 	stud.studname.toLowerCase().indexOf(liveSearch) !== -1 ||
          stud.name.toLowerCase().indexOf(liveSearch) !== -1 ||
          stud.mobile.indexOf(liveSearch) !== -1 ||
          stud.email.toLowerCase().indexOf(liveSearch) !== -1 ||
          stud.web_id.toLowerCase().indexOf(liveSearch) !== -1
      })
    }
  },
  mounted() {
    let vuemec = this;
    $.ajax({
      url: 'https://Pakainfo.com/studs',
      success(respose) {
        vuemec.studs = respose;
      }
    });
  }
});

Simple VueJS DataTables

You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example

Simple VueJS DataTables

I hope you have Got What is Simple VueJS DataTables And how it works.I would Like to have FeedBack From My Blog(Pakainfo.com) readers.Your Valuable FeedBack,Any Question,or any Comments about This Article(Pakainfo.com) Are Most Always Welcome.