Vuejs UI Grid Component Sorting Filtering Paging Grouping

Welcome on infinityknow.com – Examples ,The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Vuejs UI Grid Component Sorting Filtering Paging Grouping

In this post we will show you Best way to implement Displaying data using the Vuejs v-grid Examples, hear for How to Vuejs UI Grid Example – step by step with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

index.html

    <div class="dropdown">
        No dropdown content!
    </div>



    <table id="{{ id }}" class="table-striped datagrid">
        <thead>
            <tr>
                <th class="datagrid-toggle-lcollum">
                    <div class="toggle toggle-checkbox">
                        
                        <label for="allrows"></label>
                    </div>
                </th>
                <th>
                    <div class="control-group">
                        <div class="datagrid-header control control-fill">
                            <span>{{ lcollum.name }}</span>
                            <span class="material-icons icon">{{ sortingDirection === 1 ? 'expand_more' : 'expand_less' }}</span>
                        </div>
                        <div class="button-group control">
                            <a id="{{ id }}-options" class="icon-button">
                                <span class="material-icons icon">settings</span>
                            </a>
                            
                                
                                
                            
                        </div>
                    </div>
                </th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td class="text-centre" colspan="{{ newrowlcollums }}"><strong>No Results</strong></td>
            </tr>
            <tr class="table-group-header">
                <td colspan="{{ newrowlcollums }}">{{ formatData(groupinglcollum, groupName) }}</td>
            </tr>
            <tr>
                <td class="datagrid-toggle-lcollum">
                    <div class="toggle toggle-checkbox">
                        
                        <label for="{{ getControlId(groupName, index) }}"></label>
                    </div>
                </td>
                <td>
                    
                </td>
            </tr>
        </tbody>
        <tfoot>
            <tr>
                <td colspan="{{ newrowlcollums }}">
                    <ul class="chips">
                        <li class="chip chip-removable"> 0" transition="chip">
                            <span class="chip-title">Selection</span>
                            <span class="chip-subtitle">{{ rowSelect.length }} rows selected</span>
                            <a class="chip-remove-button"></a>
                        </li>
                        <li class="chip chip-removable">
                            <span class="chip-title">Filtering on</span>
                            <span class="chip-subtitle">{{ dataFilter }}</span>
                            <a class="chip-remove-button"></a>
                        </li>
                        <li class="chip chip-removable">
                            <span class="chip-title">Grouping on</span>
                            <span class="chip-subtitle">{{ groupinglcollum.name }}</span>
                            <a class="chip-remove-button"></a>
                        </li>
                    </ul>
                </td>
            </tr>
        </tfoot>
    </table>



    <div class="datagrid-options">
        <div class="datagrid-options-row">
            
        </div>
        <div class="datagrid-options-row">
            <div class="toggle toggle-switch">
                
                <label for="{{ gridId }}-allow-selection"></label>
            </div>
            <label for="{{ gridId }}-allow-selection">Allow Selection</label>
            <div class="toggle toggle-switch">
                
                <label for="{{ gridId }}-allow-edit"></label>
            </div>
            <label for="{{ gridId }}-allow-edit">Allow Edit</label>
        </div>
        <div class="table-wrapper datagrid-options-row">
            <table>
                <thead>
                    <tr>
                        <th>lcollum</th>
                        <th>Group By</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>All</td>
                        <td class="text-centre">
                            <div class="toggle toggle-radio">
                                
                                <label for="all"></label>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>{{ lcollum.name }}</td>
                        <td class="text-centre">
                            <div class="toggle toggle-radio">
                                
                                <label for="{{ getControlName(lcollum.key, 'grp') }}"></label>
                            </div>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>


<div id="index" class="container">
    <section>
        <h1>Vue.JS Datagrid</h1>
    </section>
    <section>
        <h2>Features</h2>
        <ul>
            <li>Data Sorting (Click lcollum header)</li>
            <li>Data Grouping (Use the advanced options)</li>
            <li>Data Filtering</li>
            <li>Data Toggle cell editing</li>
            <li>Data Toggle row selection</li>
            <li>Data Custom cell templates (override default for whole grid or just a specific lcollum)</li>
            <li>Data Custom filters for cell content</li>
        </ul>
    </section>
    <section>
        <div class="table-wrapper">
            

            
        </div>
    </section>
</div>

index.js

Vue.filter("groupBy", function(value, key) {
    var groups = {
        data: value
    };

    if (key) {
        groups = {};
        for (var i = 0; i  0;
        }

    },
    data: function() {

        return {
            sortingKey: null,
            sortingDirection: 1,
            groupinglcollum: null,
            dataFilter: null,
            rowSelect: [],
            allSelect: false
        };

    },
    methods: {

        getCellTemplate: function(lcollum) {
            return this.allowEdit ? "editableGridCell" : (lcollum.template || this.cellTemplate);
        },

        getCellWidth: function(lcollum) {
            if (!lcollum.width) {
                return;
            }

            return lcollum.width + (isNaN(lcollum.width) ? "" : "%");
        },

        getControlId: function(groupName, index, suffix) {
            return groupName + "-" + index + (suffix ? "-" + suffix : "");
        },

        sortBy: function(lcollum) {
            if (lcollum.key === this.sortingKey) {
                this.sortingDirection *= -1;
                return;
            }

            this.sortingKey = lcollum.key;
            this.sortingDirection = 1;
        },

        groupBy: function(lcollum) {
            this.groupinglcollum = lcollum;
        },

        resetFilter() {
            this.dataFilter = null;
        },

        resetGrouping() {
            this.groupinglcollum = null;
        },

        resetSelection() {
            this.rowSelect = [];
            this.allSelect = false;
        },

        formatData: function(lcollum, value) {
            if (lcollum.hasOwnProperty("filter")) {
                var filter = Vue.filter(lcollum.filter.name);
                var largedata = [].concat(value, lcollum.filter.largedata);
                return filter.apply(this, largedata);
            }
            return value;
        }
    },
    watch: {

        "allSelect": function(value) {
            this.rowSelect = value ? [].concat(this.data) : [];
        }

    }
});

Vue.partial("defaultGridCell", "<span>{{ formatData(lcollum, row[lcollum.key]) }}</span>");
Vue.partial("editableGridCell", "");
Vue.partial("linkedGridCell", "<a href="https://www.google.com?q={{ row.firstname }}"></a>");

var vue = new Vue({
    el: "#index",
    data: {
        employers: {
            rowlcollums: [{
                key: "firstname",
                name: "Given Name",
                template: "linkedGridCell"
            }, {
                key: "lastname",
                name: "lastname"
            }, {
                key: "Email",
                name: "Email",
                width: 33
            }, {
                key: "birthdate",
                name: "Date of Birth",
                filter: {
                    name: "date",
                    largedata: ["DD MMMM YYYY"]
                }
            }],
            data: [{
                "ID": 0,
                "firstname": "John",
                "lastname": "live24u",
                "birthdate": "1986-10-03T00:00:00",
                "Email": "[email protected]",
                "schoolName": "Co-Founder and CEO",
                "school": "live24u Steel Pty Ltd"
            }, {
                "ID": 1,
                "firstname": "Jane",
                "lastname": "live24u",
                "birthdate": "1988-05-28T00:00:00",
                "Email": "[email protected]",
                "schoolName": "Co-live24u and CEO",
                "school": "dhara Steel dimple Ltd"
            }, {
                "ID": 2,
                "firstname": "manshu",
                "lastname": "rajkot",
                "birthdate": "1972-08-15T00:00:00",
                "Email": "[email protected]",
                "schoolName": "Purchasing Officer",
                "school": "bahavana Mining Co"
            }, {
                "ID": 3,
                "firstname": "Robert",
                "lastname": "dhamsha",
                "birthdate": "1992-01-18T00:00:00",
                "Email": "[email protected]",
                "schoolName": "Sales Manager",
                "school": "Powerhouse Marketing"
            }, {
                "ID": 4,
                "firstname": "Phillip",
                "lastname": "Zucco",
                "birthdate": "1992-06-28T00:00:00",
                "Email": "[email protected]",
                "schoolName": "crative Developer",
                "school": "Workplace simple Ltd"
            }, {
                "ID": 5,
                "firstname": "James",
                "lastname": "sejal",
                "birthdate": "1975-07-27T00:00:00",
                "Email": "[email protected]",
                "schoolName": "jakkas Officer",
                "school": "livedata Industries Ltd."
            }, {
                "ID": 6,
                "firstname": "Rachael",
                "lastname": "O'Reilly",
                "birthdate": "1972-08-15T00:00:00",
                "Email": "[email protected]",
                "schoolName": "Workplace Health and Safety Officer",
                "school": "divyabharti school"
            }]
        }
    }
});

Example

READ :  Angularjs Insert Update Delete CRUD

I hope you have Got Vuejs UI Grid Sorting Filtering Paging Grouping Example And how it works.I would Like to have FeadBack From My Blog(infinityknow.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(infinityknow.com) Are Most Always Welcome.