ngHandsontable

Official AngularJS directive for Handsontable

Github星跟踪图

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)

主要指标

概览
名称与所有者handsontable/ngHandsontable
主编程语言JavaScript
编程语言JavaScript (语言数: 2)
平台
许可证MIT License
所有者活动
创建于2012-09-17 15:14:10
推送于2022-09-24 02:47:51
最后一次提交2020-09-01 09:23:55
发布数30
最新版本名称0.13.2 (发布于 2020-09-01 09:23:55)
第一版名称v0.3.4 (发布于 2013-03-04 00:56:14)
用户参与
星数432
关注者数52
派生数158
提交数406
已启用问题?
问题数225
打开的问题数27
拉请求数3
打开的拉请求数4
关闭的拉请求数38
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?