1.0.0-beta.13 • Published 4 years ago

zerogrid v1.0.0-beta.13

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

zeroGrid

This is for practice and learning. Do not use this grid when you work for something.

preview

Browser Support

Chrome
Latest ✔

Installing

Using npm:

npm i zerogrid

how to start

  • initialize the grid with the format
let zeroGrid = new Grid( "gridID", {
    columns: [
        {
            fieldName: "f1",
            width: 120,
            visible: true,
            header: {
                text: "NAME",
                fontSize: "12px",
                fontWeight: "bold",
                color: "#000000",
                backgroundColor: ""
            },
            body: {
                fontSize: "12px",
                fontWeight: "",
                color: "#000000",
                backgroundColor: "rgb(255, 255, 255)"
            }
        },
    ...

    ],
    data: [
        { f1: "Jack", f2: 11, f3: false, f4: "bus", f6: "Happy" },
        { f1: "Merry", f2: 21, f3: false, f4: "car", f6: "Happy" },
        { f1: "David", f2: 31, f3: true, f4: "taxi", f6: "Happy" },
        { f1: "Yang", f2: 26, f3: true, f4: "train", f6: "Happy" },
        { f1: "Kim", f2: 47, f3: false, f4: "subway", f6: "Unhappy"}
    ]
})
  • in html
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />
  <script type="text/javascript" src="/node_modules/zerogrid/dist/main.js"></script>
</head>
<body>
  <div id = "gridID">
  </div>
</body>
</html>
  • please, refer the example.
  • import zeroGrid
import Grid from 'zerogrid'

//with style...
import Grid from './node_modules/zerogrid/lib/assets/style/style.css'
  • The path that indicates main.js could be different depending on the directory structure.
  • When you use on the browser, it's okay to use main.min.js instead of main.js

API

provided method of Grid

nameparameterdescription
setColumns()columns: Array of IColumnStyledelete all column and add corresponding columns
addColumns()columns: Array of IColumnStyleadd corresponding columns
deleteColumns()fieldNames: Array of stringdelete correspoding columns
dataBind()data: Array of IRowDataadd data to the Grid and bind with view
addRows()data: Array of IRowDataadd rowData and apply on the view
deleteRows()indexes: rowIndex:numberdelete rowData and apply on the view
updateCell()rowIndex: number, fieldName: string, value:valueTypeupdate data and bind by Cell unit
setProperties()fieldNames: Array of string, propertyStyle: propStyle, value: ValueTypeupdate correspoding columns with designed propStyle
setColumnsStylefieldNames: Array of string, propertyStyle: IColumnStyleupdate correspoding columns with designed IColumnStyle

addtional reference

type ValueType = string | number | boolean;

interface IRowData{
    [fieldName:string]:ValueType;
}

interface ICellStyle {
    backgroundColor?: string;
    color?: string;
    fontWeight?: string;
    fontSize?: string;
    textAlign?: string;
    text?: string;
}

interface IColumnStyle {
    header: ICellStyle;
    body: ICellStyle;
    fieldName: string;
    visible: boolean;
    width: number;
}
propStyle: string

header.[property] || body.[property] || [property]

ex) header.color
ex2) body.backgroundColor
ex3) width

Inquiry or Advice

Please, mail : zerosheepmoo@gmail.com (Korean / English available)

License

This project is licensed under the ISC license.

1.0.0-beta.13

4 years ago

1.0.0-beta.12

4 years ago

1.0.0-beta.11

5 years ago

1.0.0-beta.10

5 years ago

1.0.0-beta.9

5 years ago

1.0.0-beta.8

5 years ago

1.0.0-beta.7

5 years ago

1.0.0-beta.6

5 years ago

1.0.0-beta.5

5 years ago

1.0.0-beta.4

5 years ago

1.0.0-beta.3

5 years ago

1.0.0-beta.2

5 years ago

1.0.0-beta.1

5 years ago

1.0.0-beta.0

5 years ago