Skip to content

Commit 5eb848f

Browse files
committed
readme
1 parent 4f2469d commit 5eb848f

File tree

2 files changed

+141
-3
lines changed

2 files changed

+141
-3
lines changed

README.md

Lines changed: 139 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,139 @@
1-
# html
2-
ActiveWidgets components (html custom elements)
1+
2+
###
3+
4+
# ActiveWidgets/HTML • Datagrid
5+
6+
[![npm version](https://img.shields.io/npm/v/@activewidgets/html)](https://www.npmjs.com/package/@activewidgets/html "View this project on npm")
7+
[![npm downloads](https://img.shields.io/npm/dm/@activewidgets/html)](https://www.npmjs.com/package/@activewidgets/html "npm package downloads/month")
8+
[![Github issues](https://img.shields.io/github/issues/activewidgets/html)](https://github.com/activewidgets/html/issues "See Github issues")
9+
[![Github repo](https://img.shields.io/github/stars/activewidgets/html?label=GitHub&style=social)](https://github.com/activewidgets/html "Open Github repo")
10+
11+
ActiveWidgets is a multi-framework UI component library. This package provides **datagrid component** as **HTML5/CustomElement**.
12+
13+
[Live demo](https://html.activewidgets.com) / [Developer guide](https://docs.activewidgets.com/guide/) / [API reference](https://docs.activewidgets.com/api/)
14+
15+
[![Datagrid demo](https://cdn.activewidgets.com/assets/screens/demo.png)](https://html.activewidgets.com)
16+
17+
- [Installation](#installation)
18+
- [Usage](#usage)
19+
- [CDN links](#cdn-links)
20+
- [Data properties](#data-properties)
21+
- [User events](#user-events)
22+
23+
24+
## Installation
25+
26+
Add [@activewidgets/html](https://docs.activewidgets.com/api/packages/html/) to your project dependencies -
27+
28+
```sh
29+
> npm i --save @activewidgets/html
30+
```
31+
32+
33+
## Usage
34+
35+
Import the library into your app to register the custom element tags -
36+
37+
```js
38+
import "@activewidgets/html";
39+
```
40+
41+
The `ax-...` tags will now function as ActiveWidgets components.
42+
43+
```html
44+
<ax-datagrid>Loading...</ax-datagrid>
45+
```
46+
47+
You can then assign properties and event handlers using standard DOM API.
48+
49+
```js
50+
const el = document.querySelector('ax-datagrid');
51+
52+
el.rows = [
53+
{ message: 'Hello, World!' }
54+
];
55+
```
56+
57+
[Live example](https://html.activewidgets.com/examples/local/hello-world/) | [Source on github](https://github.com/activewidgets/html/tree/master/examples/hello-world) | [Edit on Codesandbox](https://codesandbox.io/s/github/activewidgets/html/tree/master/examples/hello-world)
58+
59+
60+
## CDN links
61+
62+
For quick prototyping the package is also available over ActiveWidgets CDN -
63+
64+
```html
65+
<script src="https://cdn.activewidgets.com/html"></script>
66+
```
67+
68+
[Live example](https://html.activewidgets.com/examples/local/cdn-es5/) | [Source on github](https://github.com/activewidgets/html/tree/master/examples/cdn-es5) | [Edit on Codesandbox](https://codesandbox.io/s/github/activewidgets/html/tree/master/examples/cdn-es5)
69+
70+
71+
## Data properties
72+
73+
You have to provide [columns](https://docs.activewidgets.com/api/datagrid/columns/) and [rows](https://docs.activewidgets.com/api/datagrid/rows/) properties to the datagrid to show some data. The properties of each `column` object define how the data will be rendered -
74+
75+
- [field](https://docs.activewidgets.com/api/datagrid/columns/#field) - where the cell data comes from (string|function)
76+
- [header](https://docs.activewidgets.com/api/datagrid/columns/#header) - column header (string|object)
77+
- [width](https://docs.activewidgets.com/api/datagrid/columns/#width) - column width (number, in pixels)
78+
- [align](https://docs.activewidgets.com/api/datagrid/columns/#align) - cell text alignment (left|right|center)
79+
- [format](https://docs.activewidgets.com/api/datagrid/columns/#format) - number/date format (string|function)
80+
- [fixed](https://docs.activewidgets.com/api/datagrid/columns/#fixed) - fixed (true/false) for columns on the left or right side
81+
82+
The `style` (string|object) or `className` properties allow to change the styling of the column and cell elements.
83+
84+
```js
85+
const el = document.querySelector('ax-datagrid');
86+
87+
el.columns = [
88+
{ header: 'Code', field: 'customerID', width: 80, style: 'background:#def', fixed: true },
89+
{ header: 'Company Name', field: 'companyName', width: 160 },
90+
{ header: 'Contact', field: 'contactName', width: 120 },
91+
{ header: 'Title', field: 'contactTitle', width: 120 },
92+
{ header: 'Address', field: 'address', width: 120, align: 'right' }
93+
];
94+
95+
el.rows = northwind.customers;
96+
```
97+
98+
[Live example](https://html.activewidgets.com/examples/local/columns/) | [Source on github](https://github.com/activewidgets/html/tree/master/examples/columns) | [Edit on Codesandbox](https://codesandbox.io/s/github/activewidgets/html/tree/master/examples/columns)
99+
100+
101+
## User events
102+
103+
In addition to the standard DOM keyboard and mouse events the datagrid emits composite
104+
[mouse](https://docs.activewidgets.com/api/datagrid/mouse-event/) event which makes it easier to find the elements affected by the user action.
105+
106+
```js
107+
function onMouse({row}){
108+
alert(`row ${row.key} clicked!`);
109+
}
110+
111+
const el = document.querySelector('ax-datagrid');
112+
113+
el.columns = columns;
114+
el.rows = rows;
115+
116+
el.addEventListener('mouse', event => onMouse(event.detail), true);
117+
```
118+
119+
[Live example](https://html.activewidgets.com/examples/local/events/) | [Source on github](https://github.com/activewidgets/html/tree/master/examples/events) | [Edit on Codesandbox](https://codesandbox.io/s/github/activewidgets/html/tree/master/examples/events)
120+
121+
When assigning an event handler, note that the event data is passed in the `event.detail` property (we are using DOM CustomEvent class).
122+
123+
ActiveWidgets custom events do not bubble, so you should always add an event handler at the component itself, not at some parent element.
124+
125+
126+
## More info
127+
128+
- [Live demo](https://react.activewidgets.com)
129+
- [Developer guide](https://docs.activewidgets.com/guide/)
130+
- [API reference](https://docs.activewidgets.com/api/)
131+
- [Licensing](https://activewidgets.com/licenses/)
132+
- [Support forum](https://activewidgets.com/messages/)
133+
134+
135+
---
136+
137+
[![ActiveWidgets](https://activewidgets.com/include/logo/aw-logo-40.png)](https://activewidgets.com)
138+
139+

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,11 @@
6969
"url": "git+https://github.com/activewidgets/html.git"
7070
},
7171
"keywords": [
72+
"activewidgets",
7273
"datagrid"
7374
],
7475
"bugs": {
7576
"url": "https://github.com/activewidgets/html/issues"
7677
},
77-
"homepage": "https://github.com/activewidgets/html#readme"
78+
"homepage": "https://activewidgets.com"
7879
}

0 commit comments

Comments
 (0)