GithubHelp home page GithubHelp logo

isabella232 / nghandsontable Goto Github PK

View Code? Open in Web Editor NEW

This project forked from handsontable/nghandsontable

0.0 0.0 0.0 12.78 MB

Official AngularJS directive for Handsontable

Home Page: http://handsontable.github.io/ngHandsontable/

License: MIT License

JavaScript 90.96% HTML 9.04%

nghandsontable's Introduction

ngHandsontable - the AngularJS directive for Handsontable Build Status

Enables creation of data grid applications in AngularJS.

Demo

See the demo at http://handsontable.github.io/ngHandsontable.

Usage

Include the library files:

<link rel="stylesheet" media="screen" href="bower_components/handsontable/dist/handsontable.full.css">
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/handsontable/dist/handsontable.full.js"></script>
<script src="dist/ngHandsontable.js"></script>

Include component to your app:

angular.module('my-app', ['ngHandsontable']);

Template:

<hot-table settings="{colHeaders: colHeaders, contextMenu: ['row_above', 'row_below', 'remove_row'], afterChange: afterChange}"
           row-headers="false"
           min-spare-rows="minSpareRows"
           datarows="db.items"
           height="300"
           width="700">
    <hot-column data="id" title="'ID'"></hot-column>
    <hot-column data="name.first" title="'First Name'" type="grayedOut" read-only></hot-column>
    <hot-column data="name.last" title="'Last Name'" type="grayedOut" read-only></hot-column>
    <hot-column data="address" title="'Address'" width="150"></hot-column>
    <hot-column data="product.description" title="'Favorite food'" type="'autocomplete'">
        <hot-autocomplete datarows="description in product.options"></hot-autocomplete>
    </hot-column>
    <hot-column data="price" title="'Price'" type="'numeric'" width="80" format="'$ 0,0.00'"></hot-column>
    <hot-column data="isActive" title="'Is active'" type="'checkbox'" width="65" checked-template="'Yes'" unchecked-template="'No'"></hot-column>
</hot-table>

Controller:

$scope.db.items = [
  {
    "id": 1,
    "name": {
      "first": "John",
      "last": "Schmidt"
    },
    "address": "45024 France",
    "price": 760.41,
    "isActive": "Yes",
    "product": {
      "description": "Fried Potatoes",
      "options": [
        {
          "description": "Fried Potatoes",
          "image": "//a248.e.akamai.net/assets.github.com/images/icons/emoji/fries.png"
        },
        {
          "description": "Fried Onions",
          "image": "//a248.e.akamai.net/assets.github.com/images/icons/emoji/fries.png"
        }
      ]
    }
  },
  //more items go here
];

Directives and attributes specification

Main directive for creating table is <hot-table>. For defining column options you can use settings object with columns property. If you want to describe column behavior in declarative way you can add <hot-column> directive as a children of <hot-table> element and add all neccessary attributes to describe column options.

All Handsontable options listed here should be supported. Options in camelCase mode should be passed to the directive in hyphenate mode e.q autoWrapCol: true -> <hot-table auto-wrap-col>.

It's recommended to put all your settings in one big object (settings="ctrl.settings"). Settings attribute unlike any other attributes is not watched so using this can be helpful to achieve higher performance.

License

The MIT License (see the LICENSE file for the full text)

nghandsontable's People

Contributors

budnix avatar compwright avatar deenairn avatar jansiegel avatar kubak10 avatar seanthebean avatar warpech 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.