🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

ng2-handsontable

Package Overview
Dependencies
Maintainers
3
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng2-handsontable

Angular4 Handsontable components

latest
Source
npmnpm
Version
2.1.0-rc.3
Version published
Weekly downloads
173
-23.11%
Maintainers
3
Weekly downloads
 
Created
Source

ng2-handsontable

Native Angular2+ wrapper for Handsontable.

Handsontable is a data grid component with an Excel-like appearance. Built in JavaScript, it integrates with any data source and comes with features like data validation, sorting, grouping, data binding or column ordering. Actively supported by the Handsoncode team and the GitHub community.

Quick start

  • Add ng2-handsontable to your package.json or install with npm i ng2-handsontable --save.

  • If you are using SystemJS, add the ng2-handsontable path to your SystemJS.config.js: 'ng2-handsontable': 'node_modules/ng2-handsontable/bundles/ng2-handsontable.umd.js'. Webpack (used by Angular-CLI) picks up the path automatically.

  • Import the HotTableModule into your module. Here's a TypeScript example:

import { HotTableModule } from 'ng2-handsontable';
...

@NgModule({
  ...
  imports: [
    HotTableModule
  ],
  ...
})
export class MyModule {
}
  • Use the hot-table component in your template. The following example displays the supported attributes:
<hot-table [data]="data"
           [columns]="columns"
           [colHeaders]="colHeaders"
           [colWidths]="colHeaders"
           [options]="options"
           (HANDSONTABLE_EVENT)="eventHandler">
</hot-table>
  • data: any[] - data source
  • pageData: Observable<any[]> - observable data source for paged data
  • columns?: any[] - descriptors of columns that contains information regarding type, format, source, ... of particular column
  • colHeaders?: string[] - array of column headers, default column headers will be shown (or not be shown, it depends on other settings) if this parameter is undefined
  • colWidths?: number[] - array of column sizes, default column size will be applied if this parameter is undefined
  • options?: any - any of the Handsontable options
  • 'HANDSONTABLE_EVENT' - all Handsontable events are implemented as EventEmitters, e.g. (beforeInit)="onBeforeInit".

The free version of Handsontable is used by default, but the pro-version could be used as a drop-in replacement.

  • The following methods are available as a public API on HotTableComponent (which you can access from your parent component with @ViewChild(HotTableComponent) hotTableComponent):
  • getHandsontableInstance(): Handsontable - returns the underlying Handsontable Core instance; all registered Handsontable plugins are accessible via instance.getPlugin()
  • triggerOnChanges(properties: ('data' | 'options' | 'colHeaders' | 'colWidths' | 'columns')[])- Call this function to trigger the OnChanges logic for any of the given input properties, in case they were changed partially, rather than replaced by a new object. Angular would pick up the latter in ngOnChanges(), but not the former. For example, if another row has been added to the 'data' input array, call triggerOnChanges(['data']).

Troubleshooting

  • ZoneJS < 0.8.20 was throwing an error because of Handsontable's wrapping of the native Promise. If you are not able to update zone.js, you will need to import handsontable before zone.js with import 'handsontable'. For an AngularCLI-project, the zone.js import happens in the polyfill.ts file.

Please follow this guidelines when reporting bugs and feature requests:

  • Use GitHub Issues board to report bugs and feature requests (not our email address)
  • Please always write steps to reproduce the error. That way we can focus on fixing the bug, not scratching our heads trying to reproduce it.

Thanks for your understanding!

License

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

Keywords

angular

FAQs

Package last updated on 15 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts