Git Product home page Git Product logo

swangular-advancedgrid's Introduction

Shopware AngularJs -- swAngular Advanced Grid

This is an Shopware-AngularJs Component, it can be installed via Bower.

Installation

Via bower:

bower install sw-angular-advanced-grid

How to Use the Component

###Show data table The advanced grid can be used as easily as the simple grid except that options are required. The grid can be used like this:

<div sw-angular-advanced-grid ng-model="exampleData" sw-options="options"></div>

The options are defined in the controller and stored in the $scope.options variable. Options must at least consist of column definitions. Besides column definitions as fields you are allowed to define buttons which are attached to each row of the table.

  • Fields are defined by a label, column in the data set and optional horizontal weight and a renderer function.
  • Buttons are defined by a label, class, glyphicon, button and an onclick handler.

Example options may look like this:

$scope.options = {
    fields: [
        {label: 'Id', column: 'id', weight: '10'},
        {label: 'Vorname', column: 'firstname', weight: '20'},
        {label: 'Nachname', column: 'lastname', weight: '20'},
        {label: 'Alter', column: 'age', weight: '10'},
        {label: 'Qualitäten', column: 'qualities', weight: '40', renderer: function (input) {
            return input.join(', ');
        }}
    ],
    buttons: [
        {
            label: 'MyButton',
            class: '',
            glyphicon: 'edit',
            button: false,
            onclick: function (row) {
                //..
            }
        }
    ]
};

###Advanced options

The advanced grid was designed so serve as a client side interface for server side data aggregation.

By that means, all pagination and search logic is not in any way defined by this component. In fact, user interactions are converted to defined events which can be handled through listeners within the options defining controller, a service or whatever place you want.

Moreover, the grid is ready for i18n through snippets definitions.

All view components (heading, refresh button, search field, pagination, etc.) are opt in!

Advanced example options may look like this:

$scope.options = {
    heading: 'Advanced grid with meta data',
    showRefreshButton: true,
    showPagination: true,
    showItemsPerPage: true,
    showSearch: true,
    showMetaData: true,
    enableLiveEditing: true,
    paginationWidth: 3,
    fields: [
        {label: 'Id', column: 'id', weight: '10'},
        {label: 'Vorname', column: 'firstname', weight: '20', liveEditType: 'text', liveEditable: true},
        {label: 'Nachname', column: 'lastname', weight: '20', liveEditable: true},
        {label: 'Alter', column: 'age', weight: '10', liveEditable: true},
        {label: 'Qualitäten', column: 'qualities', weight: '40', renderer: function (input) {
            return input.join(', ');
        }}
    ],
    buttons: [
        {label: 'MyButton', class: '', glyphicon: 'star', button: false, onclick: function (row) {
            console.log('row is ', row);
        }},
        {label: 'Live Edit', class: '', glyphicon: 'edit', button: false, onclick: 'liveedit'}
    ],
    listeners: {
        onchangeorder: function (orderBy, orderSequence) {
            console.log('ordering by ' + orderBy + ' ' + orderSequence);
        },
        onrefresh: function () {
            console.log('refreshing');
        },
        onsearch: function(query) {
            console.log('seaching for',query);
        },
        onitemsperpagechange: function(number) {
            $scope.exampleData2.metaData.limit = number;
        },
        onchangepage: function(offset, limit) {
            console.log('limit: '+limit+', offset: '+offset);
            $scope.exampleData2.metaData.limit = limit;
            $scope.exampleData2.metaData.offset = offset;
        },
        onliveedit: function(entry) {
            console.log('edited',entry);
        }
    },
    snippets: {
        showingItems: 'Zeige',
        of: 'von',
        itemsPerPage: 'Einträge je Seite:',
        search: 'Suchen:',
        buttonChangeItemsPerPage: 'Los',
        buttonSearch: 'Los'
    }
}

###Examples

Here are some Examples

swangular-advancedgrid's People

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.