2.6.1 • Published 3 years ago

@taldor-ltd/angular-grid-cell v2.6.1

Weekly downloads
3
License
ISC
Repository
github
Last release
3 years ago

Demo

https://taldor-ltd.github.io/angular-grid-cell/

Overview

Install

npm i @taldor-ltd/angular-grid-cell moment primeicons primeng

Note: moment, primeicons and primeng are dependencies we're using internally in this repository.

Usage

Steps to your first simple grid with a two text columns.

Note: this is just a simple example to get you start with.

1. Add GridCellModule to your module's imports

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { GridCellModule } from '@taldor-ltd/angular-grid-cell';

import { AppComponent } from './app/app.component';

@NgModule({
  imports: [BrowserModule, GridCellModule],
  declarations: [AppComponent],
  bootstrap: [AppComponent]
})

class AppModule {}

platformBrowserDynamic().bootstrapModule(AppModule);

2. Add Columns[] in your component's ts file

import { Component, OnInit } from '@angular/core';

import { Column, TextElement } from '@taldor-ltd/angular-grid-cell';

@Component({
  ...
})
export class MyComponent implements OnInit {
  cars = [
    { brand: 'SEAT', model: 'IBIZA' },
    { brand: 'SUBARU', model: 'IMPREZA' }
  ];
  columns: Column[];

  constructor() { }

  ngOnInit() {
    this.columns = [
      new Column(new TextElement('brand'), { header: 'Car''s Brand' }),
      new Column(new TextElement('model'), { header: 'Car''s Model' })
    ];
  }

}

3. Create a simple html <table> and add <tld-cell> to it

<table>
  <tr>
    <th *ngFor="let col of columns">
      {{col.header}}
    </th>
  </tr>
  <tr *ngFor="let car of cars">
    <td *ngFor="let col of columns">
      <tld-cell [data]="car" [column]="col"></tld-cell>
    </td>
  </tr>
</table>

Options

Component <app-cell> options

PropertyTypeRequired
[data]any[]Required
[column]ColumnRequired

data

A reference of your data (the entire row's data)

column

A reference of the cell's column data

Column[] options

This is where the 'magic' is happening. This Column[] is basically your entire grid's configuration.

Each Column constructor's requires:

  1. Element/Element[] - this is the element/s that will render in each cell of the column

    Note: Having the ability to add multi elements in one cell is clearly one of the biggest advantages of this repository :metal: check out Element options for more details

  2. { header: '' } - this object is required for the column's header text. this object has more to it, check out extended Column options for more details

A minimal required config for a simple column looks like this:

new Column(new TextElement('fieldName'), { header: 'Some header' })

Extended Column options

All of this 'extended' options are optional

PropertyTypeRequired
fieldstring | FunctionOptional
headerClassstringOptional
widthstringOptional
alignColumnAlignOptional
containerClassstringOptional
groupByFieldstringOptional
columnIdstring | GenerateIdAttrOptional

field

headerClass

width

align

containerClass

groupByField

columnId

Element options

2.6.1

3 years ago

2.6.0

3 years ago

2.5.7

3 years ago

2.5.19

3 years ago

2.4.1

4 years ago

2.4.3

4 years ago

2.4.2

4 years ago

2.4.5

4 years ago

2.4.4

4 years ago

2.4.6

4 years ago

2.4.9

4 years ago

2.4.8

4 years ago

2.4.0

4 years ago

2.3.0

4 years ago

2.2.0

4 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.0

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago