Giter Club home page Giter Club logo

angular-open-datagrid-lib's Introduction

npm version

AngularOpenDatagrid

Demo

Preview

Install

npm install angular-open-datagrid --save

Usage

Import app.module.ts

import {AngularOpenDatagridModule} from 'angular-open-datagrid';

Add to the Imports @NgModule

imports: [
    BrowserModule,
    AppRoutingModule,
    AngularOpenDatagridModule
  ]

Use

<data-grid [pagination]="pagination" [theme]="theme"
                [columnDefs]="columnDefs" [rowData]="rowData"></data-grid>

Icons

For icons install font-awesome

npm install font-awesome --save

and include css in src/styles.scss

@import "../node_modules/font-awesome/css/font-awesome.css";

Table Options

New Options Introduced

Preview

  • Common Search: Enable common search for the table
  • Cache Search: Cache the search for the table

Pagination

  • pagination [boolean]: Enable pagination for the table.
  • pageSize [number]: Page size for the table. If pagination enabled the page size is the rows in each page.

Events

dataChanged [event]

Get data change event with parameters.

HTML

  <data-grid [pagination]="pagination" [theme]="theme"
                  [columnDefs]="columnDefs" [rowData]="rowData" (dataChanged)="valueChanged($event)" ></data-grid>

JavaScript

  valueChanged (valueChanged){
        console.log("Row: ",valueChanged.row,"Column: ",valueChanged.column, "Data: ",,valueChanged.data );
      }

dataFiltered [event]

Get data change event with parameters.

HTML

  <data-grid [pagination]="pagination" [theme]="theme"
                  [columnDefs]="columnDefs" [rowData]="rowData" (dataFiltered)="filterChanged($event)" ></data-grid>

JavaScript

  filterChanged (filterChanged){
        console.log("IsCommon: ",filterChanged.isCommon, "Column: ",filterChanged.column, "Data: ",filterChanged.filterOptions );
      }
Filter Change Event Parameters

isCommon[boolean]: If filter triggered through common filter.

column[number]: If the filter tiggered from any particular column. This field exists if only isCommon=false.

data[Array]: Filter values.

dataSorted [event]

Get column sort event with parameters.

HTML

  <data-grid [pagination]="pagination" [theme]="theme"
                  [columnDefs]="columnDefs" [rowData]="rowData" (dataSorted)="shortChanged($event)" ></data-grid>

JavaScript

  shortChanged (eventArgs){
        console.log("Column: ",eventArgs.column, "Type: ",eventArgs.type );
      }
Sorted Event Parameters

column[number]: Sort tiggered column.

type[string]: Sort type ascending(ASC) or descending (DESC).

columnRearranged [event]

Get column re-arrange event with parameters.

HTML

  <data-grid [pagination]="pagination" [theme]="theme"
                  [columnDefs]="columnDefs" [rowData]="rowData" (columnRearranged)="columnRearranged($event)" ></data-grid>

JavaScript

    columnRearranged(eventArgs){
      console.log("Change Triggered; Column:",eventArgs.column, " Moved To: ", eventArgs.movedTo);
    }
      
Re-arrange Event Parameters

column[number]: Re-arranged column number.

movedTo[number]: Final column index of the column.

Themes

  • theme [string]: Theme based table. The available themes are as follows
  1. Matrial Theme (metrial-theme)
  2. Dark Theme (dark-theme)
  3. Standard Theme (standard-theme)
  4. Red Theme (red-theme)

Column Definitions

Mandatory Options

  • headerName [string]: Header name of the particular column
  • field [string]: Field name mapping to the data rows.
  • width [number]: Width of the column in pixel.
  • sort [boolean]: Column is sortable.
  • filter [boolean]: Can filter can be filtered.
colunDefs[          
          headerName: 'Model',
          field: 'model',
          width: '40px',
          sort: true,
          filter: true
]

Optional Options

  • columnFilter [boolean]: This filter is group similar values and make a Special filter for the particular column.
  • isEdit [boolean]: Editable the prticular column.
  • cellRender [function(row, column, data, colDef)]: Custom column renderer.

Column Definition Example

columnDefs[{
          headerName: 'Model',
          field: 'model',
          width: '40',
          sort: true,
          filter: true,
          cellRender: (row, column, data, def) => {
            return '<a href="#">' + data + '</a>';
          }
        },
        {headerName: 'Make', isEdit: true, field: 'make', width: '40px'......}]

Rows

Simply array of data. Example:

rowData: [
        {make: 'Toyota', model: 'Celica', price: 35000, 'mileage': 30, color: 'red'},
        {make: 'Ford', model: 'Mondeo', price: 32000, 'mileage': 50, color: 'green'},
        .............................................................................
        ]

Binding data with table component

  <data-grid [pagination]=true [theme]="standard-theme"
                  [columnDefs]="columns" [rowData]="data"></data-grid>

Notable Features

  1. Theme based data table
  2. Column is re-arrangeable using drag-drop
  3. Row arrangable.
  4. Nice animation for visualization.
  5. Edit Cell
  6. Copy paste like Microsoft Excel.
  7. Export the data as CSV.

Demo

  1. Download the zip.
  2. Unzip and open CMD and type npm start.

Future Timeline

  1. Make more fast and smooth.

angular-open-datagrid-lib's People

Contributors

dependabot[bot] avatar sowvikr avatar sowvikroy-asl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

angular-open-datagrid-lib's Issues

Ctrl+C and Ctrl+V not working

Describe the bug
Ctrl+C for copy and Ctrl+V not working for copy and paste of rows

To Reproduce
Steps to reproduce the behavior:

  1. Go to Table
  2. Select multiple cells
  3. Press Ctrl+C
  4. Select a cell and press Ctrl+V. Not working.

Expected behavior
Select a cell and press Ctrl+V. All data pasted at proper place.

Filter caching on data change dynamically

Description
The filter of each column reset on data refresh dynamically. For now, we need an optional parameter which will allow caching the filter for each column.

Row arrange bug

This bug can be reproduced by the following steps:

  1. Select 2 or more rows
  2. Now rearrange the rows.

Now the selection checkbox and the selected rows are messed up as shown in the screenshot below:
AngularOpenDatagridLib

Row re-order css bug.

Describe the bug
The row which is dragged re-order not moving correctly up and down.

To Reproduce
Steps to reproduce the behavior:

  1. Drag A row Up and Down
  2. See the dragged row position.

Expected behavior
The row should move smoothly up and down.

Desktop (please complete the following information):

  • All Browser

Event on short a column

Feature Description
On Short any column an event fire with the following parameters.

  1. Column Number
  2. Short type (ASC/DESC)

Common filter broker

Describe the bug
Common filter not showing after set its property to 'TRUE'

To Reproduce
Steps to reproduce the behavior:

  1. Set common filter true
  2. Run data table
  3. The filter text box does not come up.

Additional context
It is broken after the dynamic row update enhancement.

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.