Coder Social home page Coder Social logo

khaled-ansary / ng2-grid Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lunzhang/ng2-grid

0.0 1.0 0.0 55 KB

Angular 2 grid layout

Home Page: https://lunzhang.github.io/ng2/#/grid

JavaScript 20.33% HTML 5.96% CSS 10.47% TypeScript 63.24%

ng2-grid's Introduction

#Angular 2 Grid Component A grid component for angular 2 application. demo

Installation


1 npm install --save ng2-grid-component

2 Import in @NgModule

import { GridModule } from 'ng2-grid-component';

@NgModule({
  imports:      [ GridModule ]....

3 Use in your component

import { NgGrid } from 'ng2-grid-component';
@Component({
    selector: 'my-app',
    template: '<grid></grid>'
})
export class AppComponent {
    @ViewChild(NgGrid) grid : NgGrid;
    ngAfterViewInit(){
      var widget = this.grid.addWidget();
    }
}

4.1 Add Custom component to @NgModule

import { CustomComponent }   from './custom/custom.component';
@NgModule({
   ...
  declarations: [CustomComponent ],
  entryComponents: [ CustomComponent ]...
})

4.2 Add Custom component to widget

import { CustomComponent } from './custom/custom.component';

var widget = this.grid.addWidget();
widget.innerComponent = CustomComponent; //or
widget.innerHTML = "<div> Hello I'm inside the widget </div>";

Systemjs Users

map: {
  'ng2-grid-component':'npm:ng2-grid-component/dist/bundles/ng2-grid.umd.min.js'....
}

Config

{
  'maxCol':5,
  'maxRow':5,
  'theme':'light',
  'colWidth':250,
  'rowHeight':180,
  'marginLeft':10,
  'marginTop':10,
  'marginRight':10,
  'marginBottom':10,
  'minWidth':1,
  'minHeight':1,
  'maxWidth':-1,
  'maxHeight':-1
}

Example

<grid [customConfig]="customConfig"></grid> .....
public customConfig = {
      'maxWidth':5,
      'maxHeight':5,
      'minWidth':2,
      'minHeight':2,
      'theme':'sky'
};

Event Handling

grid emits these events

  @Output() public onDragStart: EventEmitter<NgWidget> = new EventEmitter<NgWidget>();
  @Output() public onDrag: EventEmitter<NgWidget> = new EventEmitter<NgWidget>();
  @Output() public onDragStop: EventEmitter<NgWidget> = new EventEmitter<NgWidget>();
  @Output() public onResizeStart: EventEmitter<NgWidget> = new EventEmitter<NgWidget>();
  @Output() public onResize: EventEmitter<NgWidget> = new EventEmitter<NgWidget>();
  @Output() public onResizeStop: EventEmitter<NgWidget> = new EventEmitter<NgWidget>();

ng2-grid's People

Contributors

lunzhang avatar

Watchers

Md Khaled Hossain Ansary 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.