Giter Club home page Giter Club logo

ng2-gridstack's Introduction

ng2-gridstack

A gridstack component for Angular2. Based on gridstack.js.

Usage

Requirements

Install

NPM version

$ npm install ng2-gridstack

Basic Usage

Using SystemJs :

System.config({
    paths: {
        (...)
    },
    map: {
        'ng2-gridstack': 'npm:ng2-gridstack',
		(...)
    },
    packages: {
        app: {
        'ng2-gridstack': {
            main: './ng2-gridstack.js',
            defaultExtension: 'js'
        },
		(...)
    }

Import the component in your module

import { GridStackComponent, GridStackItemDirective } from 'ng2-gridstack'
(...)

@NgModule({
    imports: [
        (...)
    ],
    declarations: [
        GridStackComponent,
        GridStackItemDirective,
		(...)
    ],
    providers: [
		(...)
    ]
})
export class YourModule { }

ng2-gridstack can be used in two ways, either by letting the component add the items for you, or by building your own items.

First mode

<gridStack w="12" animate="true" 
	buttonClass="btn btn-default" 
	allowEditing="true" 
	[options]="gridstackOptions"
	[items]="panel.Cards" 
	(addFunction)="addCard()" 
	(saveFunction)="save($event)" 
	(deleteFunction)="deletePanel()" 
	(deleteCardFunc)="deleteCard($event)"
	[addButtonText]="'Add card'"
	[saveButtonText]="'Save panel'"
	[deleteButtonText]="'Delete panel'"
	[deleteCardButtonText]="'Delete card'">
</gridStack>

Second mode

<gridStack w="12" animate="true">
	<div gridStackItem
		[x]="0" [y]="0" [h]="3" [w]="3" [customid]="10">
		<h1>Hello</h1>
	</div>
</gridStack>

Inputs/Outputs

  • w : number of items that can fit in a row.

  • animate : grid animation on/off.

  • options (optional) : an associative array of gridstack options.

  • allowEditing : allow the edition of items on double click (false by default).

  • items (optional) : an array of objects that have the following properties.

    • x
    • y
    • width
    • height
    • customid
    • content (optional)
  • addButtonText (optional) : If present, will display a button that triggers addFunction.

  • saveButtonText (optional) : If present, will display a button that triggers saveFunction.

  • deleteButtonText (optional) : If present, will display a button that triggers deleteFunction.

  • deleteCardButtonText (optional) : If present, will display a button that triggers deleteCardFunc.

  • addFunction (optional) : this function should add a new item to the array passed in the items parameter.

  • saveFunction (optional) : calls the specified function with the updated array of items as parameter, so that you can save it.

  • deleteFunction (optional) : function to call when deleting the whole panel.

  • deleteCardFunc (optional) : function to call when a card is deleted (its customid is passed as a parameter).

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.