404
+Looks like we've got some broken links.+ + + diff --git a/animals-icons/africa.png b/animals-icons/africa.png new file mode 100644 index 000000000..fab7e31d0 Binary files /dev/null and b/animals-icons/africa.png differ diff --git a/animals-icons/asia.png b/animals-icons/asia.png new file mode 100644 index 000000000..92e6a837f Binary files /dev/null and b/animals-icons/asia.png differ diff --git a/animals-icons/cat.png b/animals-icons/cat.png new file mode 100644 index 000000000..dfaf371ac Binary files /dev/null and b/animals-icons/cat.png differ diff --git a/animals-icons/cheetah.png b/animals-icons/cheetah.png new file mode 100644 index 000000000..03cc29ab2 Binary files /dev/null and b/animals-icons/cheetah.png differ diff --git a/animals-icons/crocodile.png b/animals-icons/crocodile.png new file mode 100644 index 000000000..500a5a0b7 Binary files /dev/null and b/animals-icons/crocodile.png differ diff --git a/animals-icons/dog.png b/animals-icons/dog.png new file mode 100644 index 000000000..64023b762 Binary files /dev/null and b/animals-icons/dog.png differ diff --git a/animals-icons/elephant.png b/animals-icons/elephant.png new file mode 100644 index 000000000..e31e08531 Binary files /dev/null and b/animals-icons/elephant.png differ diff --git a/animals-icons/giraffe.png b/animals-icons/giraffe.png new file mode 100644 index 000000000..71d6e4af4 Binary files /dev/null and b/animals-icons/giraffe.png differ diff --git a/animals-icons/gorilla.png b/animals-icons/gorilla.png new file mode 100644 index 000000000..e9bfa86c5 Binary files /dev/null and b/animals-icons/gorilla.png differ diff --git a/animals-icons/horse.png b/animals-icons/horse.png new file mode 100644 index 000000000..ec56e5b34 Binary files /dev/null and b/animals-icons/horse.png differ diff --git a/animals-icons/kangaroo.png b/animals-icons/kangaroo.png new file mode 100644 index 000000000..4440a0817 Binary files /dev/null and b/animals-icons/kangaroo.png differ diff --git a/animals-icons/lion.png b/animals-icons/lion.png new file mode 100644 index 000000000..7c3e9b4c3 Binary files /dev/null and b/animals-icons/lion.png differ diff --git a/animals-icons/monkey.png b/animals-icons/monkey.png new file mode 100644 index 000000000..3d95cb9aa Binary files /dev/null and b/animals-icons/monkey.png differ diff --git a/animals-icons/penguin.png b/animals-icons/penguin.png new file mode 100644 index 000000000..52ebfc484 Binary files /dev/null and b/animals-icons/penguin.png differ diff --git a/animals-icons/rabbit.png b/animals-icons/rabbit.png new file mode 100644 index 000000000..903869aae Binary files /dev/null and b/animals-icons/rabbit.png differ diff --git a/animals-icons/rat.png b/animals-icons/rat.png new file mode 100644 index 000000000..21ade59b9 Binary files /dev/null and b/animals-icons/rat.png differ diff --git a/animals-icons/reindeer.png b/animals-icons/reindeer.png new file mode 100644 index 000000000..1624c5e9e Binary files /dev/null and b/animals-icons/reindeer.png differ diff --git a/animals-icons/rhinoceros.png b/animals-icons/rhinoceros.png new file mode 100644 index 000000000..ddfa1f113 Binary files /dev/null and b/animals-icons/rhinoceros.png differ diff --git a/animals-icons/snake.png b/animals-icons/snake.png new file mode 100644 index 000000000..e6f8ddc78 Binary files /dev/null and b/animals-icons/snake.png differ diff --git a/animals-icons/squirrel.png b/animals-icons/squirrel.png new file mode 100644 index 000000000..fd45e6db8 Binary files /dev/null and b/animals-icons/squirrel.png differ diff --git a/animals-icons/tiger.png b/animals-icons/tiger.png new file mode 100644 index 000000000..74f4239cc Binary files /dev/null and b/animals-icons/tiger.png differ diff --git a/animals-icons/turtle.png b/animals-icons/turtle.png new file mode 100644 index 000000000..a6a8360b3 Binary files /dev/null and b/animals-icons/turtle.png differ diff --git a/animals-icons/wolf.png b/animals-icons/wolf.png new file mode 100644 index 000000000..75d522b3e Binary files /dev/null and b/animals-icons/wolf.png differ diff --git a/animals-icons/world.png b/animals-icons/world.png new file mode 100644 index 000000000..845e85c57 Binary files /dev/null and b/animals-icons/world.png differ diff --git a/assets/app.js b/assets/app.js new file mode 100644 index 000000000..6378de21c --- /dev/null +++ b/assets/app.js @@ -0,0 +1,7 @@ +!function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="./",n(n.s=146)}([function(t,e){t.exports=Vue},function(t,e,n){var r=n(3),o=n(10),i=n(18),a=n(15),c=n(21),s=function(t,e,n){var u,l,d,f,h=t&s.F,p=t&s.G,m=t&s.S,v=t&s.P,g=t&s.B,y=p?r:m?r[e]||(r[e]={}):(r[e]||{}).prototype,b=p?o:o[e]||(o[e]={}),_=b.prototype||(b.prototype={});for(u in p&&(n=e),n)d=((l=!h&&y&&void 0!==y[u])?y:n)[u],f=g&&l?c(d,r):v&&"function"==typeof d?c(Function.call,d):d,y&&a(y,u,d,t&s.U),b[u]!=d&&i(b,u,f),v&&_[u]!=d&&(_[u]=d)};r.core=o,s.F=1,s.G=2,s.S=4,s.P=8,s.B=16,s.W=32,s.U=64,s.R=128,t.exports=s},function(t,e,n){"use strict";var r,o=function(){return void 0===r&&(r=Boolean(window&&document&&document.all&&!window.atob)),r},i=function(){var t={};return function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}t[e]=n}return t[e]}}(),a=[];function c(t){for(var e=-1,n=0;n
# Sort by Column
Define sort settings of each column by using sort
property.
+When you set true
value, the records are sorted by builtin logic in Cheetah Grid.
+When you set string
value, the records are sorted by builtin logic in Cheetah Grid, using the specified field.
+Please define function if you want to sort by your own logic.
<div class="sample1 demo-grid middle"></div>
+
const records = [
+ {
+ no: 1,
+ name: "Asiatic",
+ },
+ {
+ no: 2,
+ name: "South African",
+ },
+ {
+ no: 3,
+ name: "Tanzanian",
+ },
+ {
+ no: 4,
+ name: "Sudan",
+ },
+ {
+ no: 5,
+ name: "King",
+ },
+];
+const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ {
+ field: "no",
+ caption: "no",
+ width: 50,
+ // define custom sort logic
+ sort(order, col, grid) {
+ const compare =
+ order === "desc"
+ ? (v1, v2) => (v1 === v2 ? 0 : v1 > v2 ? 1 : -1)
+ : (v1, v2) => (v1 === v2 ? 0 : v1 < v2 ? 1 : -1);
+ records.sort((r1, r2) => compare(r1.no, r2.no));
+ console.log("sorted:", records);
+ grid.records = records;
+ },
+ },
+ {
+ field: "name",
+ caption: "name",
+ width: 200,
+ // use default sort logic
+ sort: true,
+ },
+ ],
+});
+grid.records = records;
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Style Properties
Property | Description | Default |
---|---|---|
sortArrowColor | Defines the color of the sort icon. | -- |
multiline | If true , accept multiline text caption. | false |
lineHeight | Define the amount of space used for lines. | -- |
autoWrapText | Define whether to wrap automatically. | -- |
lineClamp | Define truncates text at a specific number of lines. | -- |
In addition to this, the Standard styles is available.
# Color of sort arrow
In order to change the color of the sort arrow you implement as follows.
<div class="sample2 demo-grid middle"></div>
+
const records = [
+ {
+ no: 1,
+ name: "Asiatic",
+ },
+ {
+ no: 2,
+ name: "South African",
+ },
+ {
+ no: 3,
+ name: "Tanzanian",
+ },
+ {
+ no: 4,
+ name: "Sudan",
+ },
+ {
+ no: 5,
+ name: "King",
+ },
+];
+const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample2"),
+ header: [
+ {
+ field: "no",
+ caption: "no",
+ width: 50,
+ sort(order, col, grid) {
+ const compare =
+ order === "desc"
+ ? (v1, v2) => (v1 === v2 ? 0 : v1 > v2 ? 1 : -1)
+ : (v1, v2) => (v1 === v2 ? 0 : v1 < v2 ? 1 : -1);
+ records.sort((r1, r2) => compare(r1.no, r2.no));
+ grid.records = records;
+ },
+ // define color of sort arrow
+ headerStyle: { sortArrowColor: "red" },
+ },
+ {
+ field: "name",
+ caption: "name",
+ width: 200,
+ sort: true,
+ // define color of sort arrow
+ headerStyle() {
+ return { sortArrowColor: "blue" };
+ },
+ },
+ ],
+});
+grid.records = records;
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Reset
If you set sortState
property to null
, the sort state is initialized.
+(only the arrow icon of the header is initialized.)
<div class="sample3 demo-grid middle"></div>
+<button class="sample3-reset">Reset</button>
+
2
const records = [
+ {
+ no: 1,
+ name: "Asiatic",
+ },
+ {
+ no: 2,
+ name: "South African",
+ },
+ {
+ no: 3,
+ name: "Tanzanian",
+ },
+ {
+ no: 4,
+ name: "Sudan",
+ },
+ {
+ no: 5,
+ name: "King",
+ },
+];
+const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample3"),
+ header: [
+ {
+ field: "no",
+ caption: "no",
+ width: 50,
+ sort(order, col, grid) {
+ const compare =
+ order === "desc"
+ ? (v1, v2) => (v1 === v2 ? 0 : v1 > v2 ? 1 : -1)
+ : (v1, v2) => (v1 === v2 ? 0 : v1 < v2 ? 1 : -1);
+ records.sort((r1, r2) => compare(r1.no, r2.no));
+ grid.records = records;
+ },
+ },
+ {
+ field: "name",
+ caption: "name",
+ width: 200,
+ sort: true,
+ },
+ ],
+});
+grid.records = records;
+
+const button = document.querySelector(".sample3-reset");
+button.onclick = () => {
+ grid.sortState = null;
+ // does not redraw automatically, please call `invalidate`.
+ grid.invalidate();
+};
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
+ ← + + Advanced Header + + Define Multiline Text Header + + → +
# Define Header Actions
# Advanced Header Action
Define header action by using headerAction
property.
+Please select suitable Action class for headerType
of same header.
headerType | Specified headerAction by string | Description |
---|---|---|
check | 'check' | Define the behavior when checkbox is clicked. |
sort | 'sort' | Define the behavior on clicked. the default behavior is to sort the data. |
<div class="sample1 demo-grid small"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ { field: "no", caption: "no", width: 50 },
+ {
+ field: "check",
+ width: 100,
+ columnType: "check",
+ action: "check",
+ headerType: "check",
+ headerAction: "check",
+ },
+ {
+ field: "text",
+ caption: "sort",
+ width: 120,
+ action: "input",
+ headerType: "sort",
+ headerAction: "sort",
+ },
+ ],
+});
+grid.records = [
+ { no: 1, check: true, text: "abc" },
+ { no: 2, check: false, text: "def" },
+ { no: 3, check: true, text: "ghi" },
+];
+
+const { CHANGED_HEADER_VALUE, CHANGED_VALUE } = cheetahGrid.ListGrid.EVENT_TYPE;
+grid.listen(CHANGED_HEADER_VALUE, ({ value, field }) => {
+ if (field !== "check") {
+ return;
+ }
+ // header check value on change
+
+ for (const rec of grid.records) {
+ rec[field] = value;
+ }
+ grid.invalidate();
+});
+grid.listen(CHANGED_VALUE, ({ value, field }) => {
+ if (field !== "check") {
+ return;
+ }
+ // check value on change
+
+ grid.headerValues.set(field, false);
+
+ grid.invalidate();
+});
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Using Vue.js
In vue-cheetah-grid
, define the header-action
, header-type
property.
<div class="demo-grid small">
+ <c-grid
+ ref="grid"
+ :data="records">
+ <c-grid-column
+ field="no"
+ width= "50"
+ >
+ no
+ </c-grid-column>
+ <c-grid-check-column
+ field="check"
+ width="100"
+ header-type="check"
+ header-action="check"
+ @changed-header-value="onChangeHeaderValue"
+ @changed-value="onChangeValue" />
+ <c-grid-column
+ field="text"
+ width= "120"
+ header-type="sort"
+ header-action="sort"
+ >
+ sort
+ </c-grid-column>
+ </c-grid>
+</div>
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
export default {
+ data() {
+ return {
+ records: [
+ { no: 1, check: true, text: "abc" },
+ { no: 2, check: false, text: "def" },
+ { no: 3, check: true, text: "ghi" },
+ ],
+ };
+ },
+ methods: {
+ onChangeHeaderValue({ value }) {
+ // header check value on change
+ const { grid } = this.$refs;
+
+ for (const rec of this.records) {
+ rec.check = value;
+ }
+ grid.invalidate();
+ },
+ onChangeValue() {
+ // check value on change
+ const { grid } = this.$refs;
+
+ grid.headerValues.set("check", false);
+
+ grid.invalidate();
+ },
+ },
+};
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Using Header Action Class
By setting the property headerAction
as an Action instance,
+You can change the properties of the action (disable, etc.) in the when you want.
+ ← + + Define Header Styles + + Advanced Layout + + → +
# Define Header Styles
# Standard Header Style
Define header style by using headerStyle
property.
Properties below are prepared in standard.
Property | Description |
---|---|
color | Define the color of header cell. |
textAlign | Define the horizontal position of text in header cell. |
textBaseline | Define the vertical position of text in header cell. |
bgColor | Define the background color of header cell. |
font | Define the font of header cell. |
padding | Define the padding of header cell. If you set 4 values separately, please set the Array . |
textOverflow | Define how to display when text overflows the area of a header cell. clip or ellipsis is available. |
# Style Properties Per Header Type
# Simple Text Header
Additional properties are available for simple text headers:
Property | Description |
---|---|
multiline | If true , accept multiline text caption. |
lineHeight | Define the amount of space used for lines. |
autoWrapText | Define whether to wrap automatically. |
lineClamp | Define truncates text at a specific number of lines. |
# Checkbox Header
Additional properties are available for checkbox headers:
Property | Description |
---|---|
checkBgColor | Define background color of checkbox, when it is checked. |
uncheckBgColor | Define background color of checkbox, when it is unchecked. |
borderColor | Define border color of checkbox. |
# Multiline Text Header
Check out Define Multiline Text Header.
# Sort Header
Check out Sort by Column.
+ ← + + Define Cell Messages + + Sort by Column + + → +
# Define Multiline Text Header
You can display multiline text in the header by setting the headerType
property to 'multilinetext'
.
<div class="sample1 demo-grid small"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ {
+ field: "item",
+ caption: "Item\nName",
+ width: 100,
+ headerType: "multilinetext",
+ },
+ {
+ field: "amount",
+ caption: "Regular\nPrice",
+ width: 120,
+ headerType: "multilinetext",
+ },
+ ],
+});
+grid.records = [
+ { item: "abc", amount: 123 },
+ { item: "def", amount: 456 },
+ { item: "ghi", amount: 789 },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Note that simple text headers and headers with sort can also display multiline text using the style property multiline: true
.
# Style Properties
Property | Description | Default |
---|---|---|
lineHeight | Define the amount of space used for lines | -- |
autoWrapText | Define whether to wrap automatically. | -- |
lineClamp | Define truncates text at a specific number of lines. | -- |
In addition to this, the Standard styles is available.
+ ← + + Sort by Column + + Define Header Styles + + → +
# Advanced Layout
You can use the layout
property to define advanced header and record layouts.
+(In this case, the header
property cannot be used.)
The layout
property is defined by an object with the header
and the body
.
+Define an array of rows in each section, and define each element in a row.
When using the layout
property, you can set colSpan
and rowSpan
for each definition element.
For example:
<div class="sample-layout demo-grid middle"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample-layout"),
+ layout: {
+ header: [
+ // header line1
+ [
+ { caption: "ID", width: 100, rowSpan: 2 },
+ { caption: "First Name", width: 200 },
+ { caption: "Email", width: 250, rowSpan: 2 },
+ { caption: "Birthday", width: 200, rowSpan: 2 },
+ ],
+ // header line2
+ [{ caption: "Last Name" }],
+ ],
+ body: [
+ // line1
+ [
+ { field: "personid", rowSpan: 2 },
+ { field: "fname" },
+ { field: "email", rowSpan: 2 },
+ { field: getBirthday, rowSpan: 2 },
+ ],
+ // line2
+ [{ field: "lname" }],
+ ],
+ },
+ frozenColCount: 1,
+});
+grid.records = records;
+
+function getBirthday(rec) {
+ const dateTimeFormat = new Intl.DateTimeFormat("en-US", {
+ year: "numeric",
+ month: "numeric",
+ day: "numeric",
+ });
+ return dateTimeFormat.format(rec.birthday);
+}
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
+ ← + + Advanced Header + + Options and Properties + + → +
# Define Cell Messages
Define the message to display in each cell of the column by using message
property.
<div class="sample1 demo-grid small"></div>
+
const menuOptions = [
+ { value: "", label: "Empty" },
+ { value: "1", label: "Option 1" },
+ { value: "2", label: "Option 2" },
+ { value: "3", label: "Option 3" },
+ { value: "4", label: "Option 4" },
+ { value: "5", label: "Option 5" },
+ { value: "6", label: "Option 6" },
+ { value: "7", label: "Option 7" },
+];
+const displayOptions = [
+ { value: "", label: "Choose your option" },
+ { value: "1", label: "Option 1" },
+ { value: "2", label: "Option 2" },
+ { value: "3", label: "Option 3" },
+ { value: "4", label: "Option 4" },
+ { value: "5", label: "Option 5" },
+ { value: "6", label: "Option 6" },
+ { value: "7", label: "Option 7" },
+];
+
+const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ {
+ field: "text1",
+ caption: "message field",
+ width: 150,
+ //message field
+ message: "msg",
+ },
+ {
+ field: "text2",
+ caption: "input",
+ width: 150,
+ //message function
+ message(rec) {
+ return rec.text2.match(/^[a-zA-Z]*$/) ? null : "Please only alphabet.";
+ },
+ action: "input",
+ },
+ {
+ field: "text3",
+ caption: "inline input",
+ width: 150,
+ message(rec) {
+ return rec.text3.match(/^[a-zA-Z]*$/) ? null : "Please only alphabet.";
+ },
+ action: new cheetahGrid.columns.action.InlineInputEditor(),
+ },
+ {
+ field: "val4",
+ caption: "menu",
+ width: 200,
+ message(rec) {
+ return rec.val4 ? null : "Please select.";
+ },
+ columnType: new cheetahGrid.columns.type.MenuColumn({
+ options: displayOptions,
+ }),
+ action: new cheetahGrid.columns.action.InlineMenuEditor({
+ options: menuOptions,
+ }),
+ },
+ {
+ field: "check5",
+ caption: "check",
+ width: 100,
+ message(rec) {
+ return rec.check5 ? null : "Please check.";
+ },
+ columnType: "check",
+ action: "check",
+ },
+ {
+ field: "text1",
+ caption: "info",
+ width: 150,
+ message(rec) {
+ return {
+ //info message
+ type: "info",
+ message: "Info Message.",
+ };
+ },
+ },
+ {
+ field: "text1",
+ caption: "warning",
+ width: 150,
+ message(rec) {
+ return {
+ //warning message
+ type: "warning",
+ message: "Warning Message.",
+ };
+ },
+ },
+ ],
+});
+grid.records = [
+ {
+ text1: "text",
+ text2: "123",
+ text3: "123",
+ val4: "",
+ check5: false,
+ msg: "message.",
+ },
+ {
+ text1: "text",
+ text2: "123",
+ text3: "123",
+ val4: "",
+ check5: false,
+ msg: "message.",
+ },
+ {
+ text1: "text",
+ text2: "123",
+ text3: "123",
+ val4: "",
+ check5: false,
+ msg: "message.",
+ },
+ {
+ text1: "text",
+ text2: "123",
+ text3: "123",
+ val4: "",
+ check5: false,
+ msg: "message.",
+ },
+ {
+ text1: "text",
+ text2: "123",
+ text3: "123",
+ val4: "",
+ check5: false,
+ msg: "message.",
+ },
+
+ {
+ text1: "text",
+ text2: "123",
+ text3: "123",
+ val4: "",
+ check5: false,
+ msg: "message.",
+ },
+ {
+ text1: "text",
+ text2: "123",
+ text3: "123",
+ val4: "",
+ check5: false,
+ msg: "message.",
+ },
+ {
+ text1: "text",
+ text2: "123",
+ text3: "123",
+ val4: "",
+ check5: false,
+ msg: "message.",
+ },
+ {
+ text1: "text",
+ text2: "123",
+ text3: "123",
+ val4: "",
+ check5: false,
+ msg: "message.",
+ },
+ {
+ text1: "text",
+ text2: "123",
+ text3: "123",
+ val4: "",
+ check5: false,
+ msg: "message.",
+ },
+
+ {
+ text1: "text",
+ text2: "123",
+ text3: "123",
+ val4: "",
+ check5: false,
+ msg: "message.",
+ },
+ {
+ text1: "text",
+ text2: "123",
+ text3: "123",
+ val4: "",
+ check5: false,
+ msg: "message.",
+ },
+ {
+ text1: "text",
+ text2: "123",
+ text3: "123",
+ val4: "",
+ check5: false,
+ msg: "message.",
+ },
+ {
+ text1: "text",
+ text2: "123",
+ text3: "123",
+ val4: "",
+ check5: false,
+ msg: "message.",
+ },
+ {
+ text1: "text",
+ text2: "123",
+ text3: "123",
+ val4: "",
+ check5: false,
+ msg: "message.",
+ },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
+ ← + + Define Column ICON + + Advanced Header + + → +
# ButtonAction
Define the behavior when the button is clicked.
The specified method is executed after select the cell by clicking it and then push Enter.
You can control the property of disabled
and action
by manipulating the instance of ButtonAction
class.
+You can also disable each record by specifying a function for the disabled
property.
<div class="sample1 demo-grid small"></div>
+
+<label>change disabled properties : </label>
+<select class="sample1disabled">
+ <option value="" selected="true">default</option>
+ <option value="disabled">disabled = true</option>
+</select>
+<span class="sample1disabledmemo"></span><br />
+<label>change action properties : </label>
+<select class="sample1action">
+ <option value="" selected="true">Show record</option>
+ <option value="hello">Message 'Hello!'</option>
+</select>
+<span>Once you have changed, please try to click</span>
+
2
3
4
5
6
7
8
9
10
11
12
13
14
const buttonAction = new cheetahGrid.columns.action.ButtonAction({
+ action(rec) {
+ alert(JSON.stringify(rec, null, " "));
+ },
+});
+
+const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ {
+ caption: "button",
+ width: 180,
+ columnType: new cheetahGrid.columns.type.ButtonColumn({
+ caption: "BUTTON",
+ }),
+ action: buttonAction,
+ },
+ ],
+});
+grid.records = [
+ { no: 1 /* ・・・ */ },
+ { no: 2 /* ・・・ */ },
+ { no: 3 /* ・・・ */ },
+];
+
+document.querySelector(".sample1disabled").onchange = function () {
+ //change disabled properties
+ if (this.value === "disabled") {
+ buttonAction.disabled = true;
+ document.querySelector(".sample1disabledmemo").textContent =
+ "It will not toggle and does not respond when hovering the mouse";
+ } else {
+ buttonAction.disabled = false;
+ document.querySelector(".sample1disabledmemo").textContent = "default";
+ }
+};
+
+document.querySelector(".sample1action").onchange = function () {
+ //change action properties
+ if (this.value === "hello") {
+ buttonAction.action = () => {
+ alert("Hello!");
+ };
+ } else {
+ buttonAction.action = (rec) => {
+ alert(JSON.stringify(rec, null, " "));
+ };
+ }
+};
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
+ ← + + Column Action Classes + + CheckEditor + + → +
# CheckEditor
Define the behavior and data editing when checkbox is clicked.
The record is edited after select the cell by clicking it and then push Enter or Space.
You can control the property of readOnly
and disabled
by setting the instance of CheckEditor
class to action
of the column.
+But if you define 'check'
, as string, to action
of the column, you can't control these properties.
+You can also disable or read-only each record by specifying a function for the disabled
and readOnly
properties.
<div class="sample1 demo-grid small"></div>
+
+<label>change action properties : </label>
+<select class="sample1mode">
+ <option value="" selected="true">both false</option>
+ <option value="readOnly">readOnly = true</option>
+ <option value="disabled">disabled = true</option>
+</select>
+<span class="sample1modememo"></span>
+
2
3
4
5
6
7
8
9
const checkEditorAction = new cheetahGrid.columns.action.CheckEditor();
+const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ {
+ field: "check1",
+ caption: "defined by string",
+ width: 220,
+ columnType: "check",
+ action: "check",
+ },
+
+ //
+ {
+ field: "check2",
+ caption: "defined by class instance",
+ width: 220,
+ columnType: "check",
+ action: checkEditorAction,
+ },
+
+ {
+ caption: "show",
+ width: 100,
+ columnType: new cheetahGrid.columns.type.ButtonColumn({
+ caption: "SHOW",
+ }),
+ action: new cheetahGrid.columns.action.ButtonAction({
+ action(rec) {
+ alert(JSON.stringify(rec, null, " "));
+ },
+ }),
+ },
+ ],
+});
+grid.records = [
+ { check1: true, check2: false },
+ { check1: false, check2: true },
+ { check1: true, check2: false },
+];
+
+document.querySelector(".sample1mode").onchange = function () {
+ //change action properties
+ if (this.value === "readOnly") {
+ checkEditorAction.readOnly = true;
+ checkEditorAction.disabled = false;
+ document.querySelector(".sample1modememo").textContent =
+ "It will not toggle";
+ } else if (this.value === "disabled") {
+ checkEditorAction.readOnly = false;
+ checkEditorAction.disabled = true;
+ document.querySelector(".sample1modememo").textContent =
+ "It will not toggle and does not respond when hovering the mouse";
+ } else {
+ checkEditorAction.readOnly = false;
+ checkEditorAction.disabled = false;
+ document.querySelector(".sample1modememo").textContent = "both false";
+ }
+};
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Data editing
Basic behavior is switching true
and false
.
Switchings shown below can be done as the special behavior.
Type | Truthy Value | Falsy Value |
---|---|---|
number | 1 | 0 |
string | 'true' | 'false' |
string | 'on' | 'off' |
string | '1' | '0' |
string | '01' | '00' |
string | '00001' | '00000' |
The value regarded as truthy value in JavaScript is switched to false
.
+The value regarded as falsy value is switched to true
.
All numbers except 0
are switched to 0
.
+In this case, the original number will not be restored when switching again.
<div class="sample2 demo-grid small"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample2"),
+ header: [
+ {
+ field: "boolean",
+ caption: "true/false",
+ width: 100,
+ columnType: "check",
+ action: "check",
+ },
+ {
+ field: "num",
+ caption: "1/0",
+ width: 100,
+ columnType: "check",
+ action: "check",
+ },
+ {
+ field: "truefalse",
+ caption: "'true'/'false'",
+ width: 100,
+ columnType: "check",
+ action: "check",
+ },
+ {
+ field: "onoff",
+ caption: "on/off",
+ width: 100,
+ columnType: "check",
+ action: "check",
+ },
+ {
+ field: "onezero",
+ caption: "'1'/'0'",
+ width: 100,
+ columnType: "check",
+ action: "check",
+ },
+ {
+ field: "numstring",
+ caption: "num string",
+ width: 100,
+ columnType: "check",
+ action: "check",
+ },
+ {
+ caption: "show",
+ width: 100,
+ columnType: new cheetahGrid.columns.type.ButtonColumn({
+ caption: "SHOW",
+ }),
+ action: new cheetahGrid.columns.action.ButtonAction({
+ action(rec) {
+ alert(JSON.stringify(rec, null, " "));
+ },
+ }),
+ },
+ ],
+});
+grid.records = [
+ {
+ boolean: true,
+ num: 0,
+ truefalse: "true",
+ onoff: "off",
+ onezero: "1",
+ numstring: "00",
+ },
+ {
+ boolean: false,
+ num: 1,
+ truefalse: "false",
+ onoff: "on",
+ onezero: "0",
+ numstring: "0001",
+ },
+ {
+ boolean: true,
+ num: 0,
+ truefalse: "true",
+ onoff: "off",
+ onezero: "1",
+ numstring: "00000000000",
+ },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# disabled
You can control disabled
depending on the state of the record by giving disabled
a function
.
<div class="sample3 demo-grid small"></div>
+
const checkEditorAction = new cheetahGrid.columns.action.CheckEditor();
+checkEditorAction.disabled = (record) => record.disabled;
+
+const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample3"),
+ header: [
+ {
+ field: "test",
+ caption: "disabled?",
+ width: 220,
+ columnType: "check",
+ action: checkEditorAction,
+ },
+
+ //
+ {
+ field: "disabled",
+ caption: "control",
+ width: 220,
+ columnType: "check",
+ action: "check",
+ },
+ ],
+});
+grid.records = [
+ { disabled: true, test: false },
+ { disabled: false, test: true },
+ { disabled: true, test: false },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+ ← + + ButtonAction + + SmallDialogInputEditor + + → +
# Column Action Classes
# Namespace cheetahGrid.columns.action
Class Name | Function | Others |
---|---|---|
CheckEditor | The behavior when clicking the checkbox | same as action: 'check' |
ButtonAction | The behavior when clicking the button | --- |
SmallDialogInputEditor | The behavior when input the cell (Material Design Small edit dialog) | same as action: 'input' |
InlineInputEditor | The behavior when input the cell | InlineInputEditor is an experiment stage |
InlineMenuEditor | The behavior when select menu the cell | --- |
RadioEditor | The behavior when clicking the radio button | same as action: 'radio' |
# Standard Properties
+ ← + + Define Column Actions + + ButtonAction + + → +
# InlineInputEditor
Enables data editing by input.
<div class="sample1 demo-grid small"></div>
+
+<label>change action properties : </label>
+<select class="sample1mode">
+ <option value="" selected="true">both false</option>
+ <option value="readOnly">readOnly = true</option>
+ <option value="disabled">disabled = true</option>
+</select>
+<span class="sample1modememo"></span>
+
2
3
4
5
6
7
8
9
const inputEditor = new cheetahGrid.columns.action.InlineInputEditor();
+const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ {
+ field: "text",
+ caption: "defined by InlineInputEditor",
+ width: 260,
+ action: inputEditor,
+ },
+
+ {
+ caption: "show",
+ width: 100,
+ columnType: new cheetahGrid.columns.type.ButtonColumn({
+ caption: "SHOW",
+ }),
+ action: new cheetahGrid.columns.action.ButtonAction({
+ action(rec) {
+ alert(JSON.stringify(rec, null, " "));
+ },
+ }),
+ },
+ ],
+});
+grid.records = [
+ { text: "text" },
+ { text: "text" },
+ { text: "text" },
+ { text: "text" },
+ { text: "text" },
+ { text: "text" },
+ { text: "text" },
+ { text: "text" },
+ { text: "text" },
+ { text: "text" },
+];
+
+document.querySelector(".sample1mode").onchange = function () {
+ //change action properties
+ if (this.value === "readOnly") {
+ inputEditor.readOnly = true;
+ inputEditor.disabled = false;
+ document.querySelector(".sample1modememo").textContent =
+ "It will not toggle";
+ } else if (this.value === "disabled") {
+ inputEditor.readOnly = false;
+ inputEditor.disabled = true;
+ document.querySelector(".sample1modememo").textContent =
+ "It will not toggle and does not respond when hovering the mouse";
+ } else {
+ inputEditor.readOnly = false;
+ inputEditor.disabled = false;
+ document.querySelector(".sample1modememo").textContent = "both false";
+ }
+};
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Properties
Property | Description |
---|---|
type | Specify the type attribute of the <input> element. |
classList | Specify class of the <input> element. |
<div class="sample2 demo-grid small"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample2"),
+ header: [
+ {
+ field: "number",
+ caption: "type & classList",
+ width: 220,
+ columnType: "number",
+ action: new cheetahGrid.columns.action.InlineInputEditor({
+ type: "number",
+ classList: ["al-right"],
+ }),
+ },
+ {
+ caption: "show",
+ width: 100,
+ columnType: new cheetahGrid.columns.type.ButtonColumn({
+ caption: "SHOW",
+ }),
+ action: new cheetahGrid.columns.action.ButtonAction({
+ action(rec) {
+ alert(JSON.stringify(rec, null, " "));
+ },
+ }),
+ },
+ ],
+});
+grid.records = [{ number: 1234 }, { number: 1234.123 }, { number: -1234.123 }];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
.al-right {
+ text-align: right;
+}
+
2
3
+ ← + + SmallDialogInputEditor + + InlineMenuEditor + + → +
# InlineMenuEditor
Enables data editing by menu selection.
<div class="sample1 demo-grid small"></div>
+
+<label>change action properties : </label>
+<select class="sample1mode">
+ <option value="" selected="true">both false</option>
+ <option value="readOnly">readOnly = true</option>
+ <option value="disabled">disabled = true</option>
+</select>
+<span class="sample1modememo"></span>
+
2
3
4
5
6
7
8
9
const menuOptions = [
+ { value: "", label: "Empty" },
+ { value: "1", label: "Option 1" },
+ { value: "2", label: "Option 2" },
+ { value: "3", label: "Option 3" },
+ { value: "4", label: "Option 4" },
+ { value: "5", label: "Option 5" },
+ { value: "6", label: "Option 6" },
+ { value: "7", label: "Option 7" },
+];
+const displayOptions = [
+ { value: "", label: "Choose your option" },
+ { value: "1", label: "Option 1" },
+ { value: "2", label: "Option 2" },
+ { value: "3", label: "Option 3" },
+ { value: "4", label: "Option 4" },
+ { value: "5", label: "Option 5" },
+ { value: "6", label: "Option 6" },
+ { value: "7", label: "Option 7" },
+];
+const menuEditor = new cheetahGrid.columns.action.InlineMenuEditor({
+ options: menuOptions,
+});
+const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ {
+ field: "sel",
+ caption: "InlineMenuEditor",
+ width: 260,
+ columnType: new cheetahGrid.columns.type.MenuColumn({
+ options: displayOptions,
+ }),
+ action: new cheetahGrid.columns.action.InlineMenuEditor({
+ options: menuOptions,
+ }),
+ },
+ {
+ field: "sel2",
+ caption: "controlable properties",
+ width: 260,
+ columnType: new cheetahGrid.columns.type.MenuColumn({
+ options: displayOptions,
+ }),
+ action: menuEditor,
+ },
+
+ {
+ caption: "show",
+ width: 100,
+ columnType: new cheetahGrid.columns.type.ButtonColumn({
+ caption: "SHOW",
+ }),
+ action: new cheetahGrid.columns.action.ButtonAction({
+ action(rec) {
+ alert(JSON.stringify(rec, null, " "));
+ },
+ }),
+ },
+ ],
+});
+grid.records = [
+ { sel: "", sel2: "" },
+ { sel: "1", sel2: "1" },
+ { sel: "2", sel2: "2" },
+ { sel: "3", sel2: "3" },
+ { sel: "", sel2: "" },
+ { sel: "1", sel2: "1" },
+ { sel: "2", sel2: "2" },
+ { sel: "3", sel2: "3" },
+ { sel: "", sel2: "" },
+ { sel: "1", sel2: "1" },
+ { sel: "2", sel2: "2" },
+ { sel: "3", sel2: "3" },
+];
+document.querySelector(".sample1mode").onchange = function () {
+ //change action properties
+ if (this.value === "readOnly") {
+ menuEditor.readOnly = true;
+ menuEditor.disabled = false;
+ document.querySelector(".sample1modememo").textContent =
+ "It will not toggle";
+ } else if (this.value === "disabled") {
+ menuEditor.readOnly = false;
+ menuEditor.disabled = true;
+ document.querySelector(".sample1modememo").textContent =
+ "It will not toggle and does not respond when hovering the mouse";
+ } else {
+ menuEditor.readOnly = false;
+ menuEditor.disabled = false;
+ document.querySelector(".sample1modememo").textContent = "both false";
+ }
+};
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
+ ← + + InlineInputEditor + + RadioEditor + + → +
# RadioEditor
Define the behavior and data editing when radio button is clicked.
The record is edited after select the cell by clicking it and then push Enter or Space.
You can control the property of readOnly
and disabled
by setting the instance of RadioEditor
class to action
of the column.
+But if you define 'radio'
, as string, to action
of the column, you can't control these properties.
+You can also disable or read-only each record by specifying a function for the disabled
and readOnly
properties.
<div class="sample1 demo-grid small"></div>
+
+<label>change action properties : </label>
+<select class="sample1mode">
+ <option value="" selected="true">both false</option>
+ <option value="readOnly">readOnly = true</option>
+ <option value="disabled">disabled = true</option>
+</select>
+<span class="sample1modememo"></span>
+
2
3
4
5
6
7
8
9
const radioEditorAction = new cheetahGrid.columns.action.RadioEditor();
+const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ {
+ field: "check1",
+ caption: "Defined by string",
+ width: 220,
+ columnType: "radio",
+ action: "radio",
+ },
+
+ //
+ {
+ field: "check2",
+ caption: "Defined by class instance",
+ width: 220,
+ columnType: "radio",
+ action: radioEditorAction,
+ },
+
+ {
+ caption: "Show",
+ width: 100,
+ columnType: new cheetahGrid.columns.type.ButtonColumn({
+ caption: "SHOW",
+ }),
+ action: new cheetahGrid.columns.action.ButtonAction({
+ action(rec) {
+ alert(JSON.stringify(rec, null, " "));
+ },
+ }),
+ },
+ ],
+});
+grid.records = [
+ { check1: true, check2: false },
+ { check1: false, check2: true },
+ { check1: false, check2: false },
+];
+
+document.querySelector(".sample1mode").onchange = function () {
+ //change action properties
+ if (this.value === "readOnly") {
+ radioEditorAction.readOnly = true;
+ radioEditorAction.disabled = false;
+ document.querySelector(".sample1modememo").textContent =
+ "It will not toggle";
+ } else if (this.value === "disabled") {
+ radioEditorAction.readOnly = false;
+ radioEditorAction.disabled = true;
+ document.querySelector(".sample1modememo").textContent =
+ "It will not toggle and does not respond when hovering the mouse";
+ } else {
+ radioEditorAction.readOnly = false;
+ radioEditorAction.disabled = false;
+ document.querySelector(".sample1modememo").textContent = "both false";
+ }
+};
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# disabled
You can control disabled
depending on the state of the record by giving disabled
a function
.
<div class="sample3 demo-grid small"></div>
+
const radioEditorAction = new cheetahGrid.columns.action.RadioEditor();
+radioEditorAction.disabled = (record) => record.disabled;
+
+const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample3"),
+ header: [
+ {
+ field: "test",
+ caption: "disabled?",
+ width: 220,
+ columnType: "radio",
+ action: radioEditorAction,
+ },
+
+ //
+ {
+ field: "disabled",
+ caption: "control",
+ width: 220,
+ columnType: "check",
+ action: "check",
+ },
+ ],
+});
+grid.records = [
+ { disabled: true, test: false },
+ { disabled: false, test: true },
+ { disabled: true, test: false },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+ ← + + InlineMenuEditor + + Standard Properties + + → +
# SmallDialogInputEditor
Enables data editing by input.
You can dynamically control the readOnly
and disabled
property by defining an instance of the SmallDialogInputEditor
class to the action
column.
+But if you define 'input'
, as string, to action
of the column, you can't control these properties.
+You can also disable or read-only each record by specifying a function for the disabled
and readOnly
properties.
<div class="sample1 demo-grid small"></div>
+
+<label>change action properties : </label>
+<select class="sample1mode">
+ <option value="" selected="true">both false</option>
+ <option value="readOnly">readOnly = true</option>
+ <option value="disabled">disabled = true</option>
+</select>
+<span class="sample1modememo"></span>
+
2
3
4
5
6
7
8
9
const inputEditor = new cheetahGrid.columns.action.SmallDialogInputEditor();
+const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ {
+ field: "text1",
+ caption: "defined by string",
+ width: 220,
+ action: "input",
+ },
+
+ //
+ {
+ field: "text2",
+ caption: "defined by class instance",
+ width: 220,
+ action: inputEditor,
+ },
+
+ {
+ caption: "show",
+ width: 100,
+ columnType: new cheetahGrid.columns.type.ButtonColumn({
+ caption: "SHOW",
+ }),
+ action: new cheetahGrid.columns.action.ButtonAction({
+ action(rec) {
+ alert(JSON.stringify(rec, null, " "));
+ },
+ }),
+ },
+ ],
+});
+grid.records = [
+ { text1: "text", text2: "text" },
+ { text1: "text", text2: "text" },
+ { text1: "text", text2: "text" },
+ { text1: "text", text2: "text" },
+ { text1: "text", text2: "text" },
+ { text1: "text", text2: "text" },
+ { text1: "text", text2: "text" },
+ { text1: "text", text2: "text" },
+ { text1: "text", text2: "text" },
+ { text1: "text", text2: "text" },
+];
+
+document.querySelector(".sample1mode").onchange = function () {
+ //change action properties
+ if (this.value === "readOnly") {
+ inputEditor.readOnly = true;
+ inputEditor.disabled = false;
+ document.querySelector(".sample1modememo").textContent =
+ "It will not toggle";
+ } else if (this.value === "disabled") {
+ inputEditor.readOnly = false;
+ inputEditor.disabled = true;
+ document.querySelector(".sample1modememo").textContent =
+ "It will not toggle and does not respond when hovering the mouse";
+ } else {
+ inputEditor.readOnly = false;
+ inputEditor.disabled = false;
+ document.querySelector(".sample1modememo").textContent = "both false";
+ }
+};
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Properties
The following properties can be set with the constructor argument of SmallDialogInputEditor
.
Property | Description |
---|---|
type | Specify the type attribute of the <input> element. |
classList | Specify class of the dialog element. |
helperText | Specify helper text. You can also specify a function. |
validator | Specify the validation function to be call before confirming the input value. If there is an error, please use the function to return the message. |
inputValidator | Specify the validation function of the value of <input> . If there is an error, please use the function to return the message. |
<div class="sample2 demo-grid small"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample2"),
+ header: [
+ {
+ field: "number",
+ caption: "type & classList",
+ width: 220,
+ columnType: "number",
+ action: new cheetahGrid.columns.action.SmallDialogInputEditor({
+ type: "number",
+ classList: ["al-right"],
+ }),
+ },
+ {
+ field: "text",
+ caption: "validator & helperText",
+ width: 220,
+ action: new cheetahGrid.columns.action.SmallDialogInputEditor({
+ classList: "helper-text--right-justified",
+ helperText(value) {
+ return `${value.length}/20`;
+ },
+ inputValidator(value) {
+ return value.length > 20
+ ? `over the max length. ${value.length}`
+ : null;
+ },
+ validator(value) {
+ return value.match(/^[a-zA-Z]*$/) ? null : "Please only alphabet.";
+ },
+ }),
+ },
+ {
+ field: "code",
+ caption: "async validator",
+ width: 220,
+ action: new cheetahGrid.columns.action.SmallDialogInputEditor({
+ helperText: "enter code. /^[A-Z]\\d{3}$/",
+ validator(value) {
+ return new Promise((r) => {
+ setTimeout(() => {
+ r(value.match(/^[A-Z]\d{3}$/) ? null : "Invalid code.");
+ }, 500);
+ });
+ },
+ }),
+ },
+ {
+ caption: "show",
+ width: 100,
+ columnType: new cheetahGrid.columns.type.ButtonColumn({
+ caption: "SHOW",
+ }),
+ action: new cheetahGrid.columns.action.ButtonAction({
+ action(rec) {
+ alert(JSON.stringify(rec, null, " "));
+ },
+ }),
+ },
+ ],
+});
+grid.records = [
+ { number: 1234, text: "a", code: "A001" },
+ { number: 1234.123, text: "b", code: "A002" },
+ { number: -1234.123, text: "c", code: "A003" },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
.al-right input {
+ text-align: right;
+}
+
2
3
+ ← + + CheckEditor + + InlineInputEditor + + → +
# Define Column Actions
# Standard Column Action
Define column action by using action
property.
+Please select suitable Action class for columnType
of same column.
columnType | Specified action by string | Description | LINK |
---|---|---|---|
check | 'check' | Define the behavior when checkbox is clicked. | CheckEditor |
button | --- | Define the behavior when button is clicked. | ButtonAction |
input | 'input' | Define the behavior when cell input. | SmallDialogInputEditor |
MenuColumn | --- | Define the behavior when select a menu. | InlineMenuEditor |
radio | 'radio' | Define the behavior when radio button is clicked. | RadioEditor |
<div class="sample1 demo-grid small"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ { field: "no", caption: "no", width: 50 },
+ // action: 'check'
+ {
+ field: "check",
+ caption: "check",
+ width: 60,
+ columnType: "check",
+ action: "check",
+ },
+ // action: 'input'
+ { field: "text", caption: "input", width: 120, action: "input" },
+ {
+ caption: "button",
+ width: 100,
+ columnType: new cheetahGrid.columns.type.ButtonColumn({
+ caption: "show rec",
+ }),
+ // ButtonAction
+ action: new cheetahGrid.columns.action.ButtonAction({
+ action(rec) {
+ alert(JSON.stringify(rec));
+ },
+ }),
+ },
+ ],
+});
+grid.records = [
+ { no: 1, check: true, text: "abc" },
+ { no: 2, check: false, text: "def" },
+ { no: 3, check: true, text: "ghi" },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Advanced Column Action
By setting the property action
as an Action instance,
+You can change the properties of the action (disable, readonly, etc.) in the when you want.
Please refer to here
+ ← + + Define Column Styles + + Column Action Classes + + → +
# Standard Properties
Action classes have some common properties. +Here, they will be described.
# disabled
property
If set to true
, the action will be disabled.
+You can also control disabled
for each record by specifying a function.
const alwaysDisabledButtonAction = new cheetahGrid.columns.action.ButtonAction({
+ disabled: true,
+ action(rec) {
+ alert("Clicked Button!");
+ },
+});
+const DisabledForEachRecordButtonAction =
+ new cheetahGrid.columns.action.ButtonAction({
+ disabled: (rec) => rec.disabled,
+ action(rec) {
+ alert("Clicked Button!");
+ },
+ });
+
+const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ {
+ caption: "Always Disabled",
+ width: 180,
+ columnType: new cheetahGrid.columns.type.ButtonColumn({
+ caption: "BUTTON",
+ }),
+ action: alwaysDisabledButtonAction,
+ },
+ {
+ caption: "Disabled",
+ field: "disabled",
+ columnType: "check",
+ action: "check",
+ },
+ {
+ caption: "Disabled for Each Record",
+ width: 180,
+ columnType: new cheetahGrid.columns.type.ButtonColumn({
+ caption: "BUTTON",
+ }),
+ action: DisabledForEachRecordButtonAction,
+ },
+ ],
+});
+grid.records = [{ disabled: false }, { disabled: false }, { disabled: false }];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<div class="sample1 demo-grid small"></div>
+
# readOnly
property
If set to true
, the action will be read-only.
+As with disabled
, you can also specify a function.
+ ← + + RadioEditor + + Grid Data + + → +
# Define Column ICON
Use icon
property when drawing icons.
You can use 2 types of icons below by setting.
- ICON by Web Font
- ICON by picture
# Standard way to specify Web Fonts
For standard Web font, you should set font
and content
.
<div class="sample1 demo-grid small"></div>
+
ICON in sample uses Font Awesome Icons (opens new window)
<!-- Font Awesome: http://fontawesome.io --> +<link + rel="stylesheet" + type="text/css" + href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" +/> +
1
2
3
4
5
6
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ {
+ caption: "text",
+ width: 180,
+ icon: {
+ font: "normal normal normal 14px/1 FontAwesome",
+ content: "iconContent",
+ width: 16, // Optional
+ },
+ field: "text",
+ },
+
+ {
+ caption: "button",
+ width: 180,
+ icon: {
+ font: "normal normal normal 14px/1 FontAwesome",
+ content: "iconContent",
+ width: 16, // Optional
+ },
+ columnType: new cheetahGrid.columns.type.ButtonColumn({
+ caption: "BUTTON",
+ }),
+ action: new cheetahGrid.columns.action.ButtonAction({
+ action(rec) {
+ alert(JSON.stringify(rec));
+ },
+ }),
+ },
+ ],
+});
+grid.records = [
+ { text: "file", iconContent: "\uf15b" },
+ { text: "audio", iconContent: "\uf1c7" },
+ { text: "code", iconContent: "\uf1c9" },
+ { text: "image", iconContent: "\uf1c5" },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Other ways to specify Web Font
You can use web font by setting className
.
<div class="sample2 demo-grid small"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample2"),
+ header: [
+ {
+ caption: "text",
+ width: 180,
+ icon: {
+ className: "iconClassName",
+ width: 16, // Optional
+ },
+ field: "text",
+ },
+
+ {
+ caption: "button",
+ width: 180,
+ icon: {
+ className: "iconClassName",
+ width: 16, // Optional
+ color: "#fff", // Optional
+ },
+ columnType: new cheetahGrid.columns.type.ButtonColumn({
+ caption: "BUTTON",
+ }),
+ action: new cheetahGrid.columns.action.ButtonAction({
+ action(rec) {
+ alert(JSON.stringify(rec));
+ },
+ }),
+ },
+ ],
+});
+grid.records = [
+ { text: "file", iconClassName: "fa fa-file" },
+ { text: "audio", iconClassName: "fa fa-file-audio-o" },
+ { text: "code", iconClassName: "fa fa-file-code-o" },
+ { text: "image", iconClassName: "fa fa-file-image-o" },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# How to specify Images
Set src
to show pictures.
<div class="sample3 demo-grid small"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample3"),
+ header: [
+ {
+ caption: "OSS",
+ width: 300,
+ icon: {
+ src: "iconSrc",
+ width: 16,
+ },
+ field: "label",
+ },
+ {
+ caption: "link",
+ width: 150,
+ icon: {
+ src: "iconSrc",
+ width: 16,
+ },
+ columnType: new cheetahGrid.columns.type.ButtonColumn({
+ caption: "LINK",
+ }),
+ action: new cheetahGrid.columns.action.ButtonAction({
+ action(rec) {
+ window.open(rec.url, "_blank");
+ },
+ }),
+ },
+ ],
+});
+grid.records = [
+ {
+ label: "Vuls: VULnerability Scanner",
+ iconSrc:
+ "https://github.com/future-architect/vuls/raw/master/img/vuls_icon.png",
+ url: "https://github.com/future-architect/vuls",
+ },
+ {
+ label: "uroboroSQL",
+ iconSrc: "https://future-architect.github.io/uroborosql-doc/favicon.ico",
+ url: "https://future-architect.github.io/uroborosql-doc/",
+ },
+ {
+ label: "Urushi",
+ iconSrc:
+ "http://future-architect.github.io/urushi/gh-pages-resoucres/favicon.ico",
+ url: "http://future-architect.github.io/urushi/",
+ },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Multiple Icons
Give array in order to show multiple icons.
<div class="sample4 demo-grid small"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample4"),
+ header: [
+ {
+ caption: "text",
+ width: 180,
+ icon: {
+ font: "normal normal normal 14px/1 FontAwesome",
+ content: "iconContent",
+ width: 16, // Optional
+ },
+ field: "text",
+ },
+
+ {
+ caption: "button",
+ width: 180,
+ icon: {
+ font: "normal normal normal 14px/1 FontAwesome",
+ content: "iconContent",
+ width: 16, // Optional
+ },
+ columnType: new cheetahGrid.columns.type.ButtonColumn({
+ caption: "BUTTON",
+ }),
+ action: new cheetahGrid.columns.action.ButtonAction({
+ action(rec) {
+ alert(JSON.stringify(rec));
+ },
+ }),
+ },
+ ],
+});
+grid.records = [
+ { text: "files", iconContent: ["\uf15b", "\uf1c7", "\uf1c9", "\uf1c5"] },
+ { text: "forms", iconContent: ["\uf046", "\uf192", "\uf0fe", "\uf147"] },
+ { text: "charts", iconContent: ["\uf1fe", "\uf080", "\uf200"] },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<div class="sample5 demo-grid small"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample5"),
+ header: [
+ {
+ caption: "OSS",
+ width: 300,
+ icon: {
+ src: "iconSrc",
+ width: 16,
+ },
+ field: "label",
+ },
+ {
+ caption: "link",
+ width: 150,
+ icon: {
+ src: "iconSrc",
+ width: 16,
+ },
+ columnType: new cheetahGrid.columns.type.ButtonColumn({
+ caption: "LINK",
+ }),
+ action: new cheetahGrid.columns.action.ButtonAction({
+ action(rec) {
+ window.open(rec.url, "_blank");
+ },
+ }),
+ },
+ ],
+});
+const vulsIconUrl =
+ "https://github.com/future-architect/vuls/raw/master/img/vuls_icon.png";
+const uroboroSQLIconUrl =
+ "https://future-architect.github.io/uroborosql-doc/favicon.ico";
+const urushiIconUrl =
+ "http://future-architect.github.io/urushi/gh-pages-resoucres/favicon.ico";
+grid.records = [
+ {
+ label: "Vuls: VULnerability Scanner",
+ iconSrc: [vulsIconUrl, vulsIconUrl, vulsIconUrl, vulsIconUrl],
+ url: "https://github.com/future-architect/vuls",
+ },
+ {
+ label: "uroboroSQL",
+ iconSrc: [uroboroSQLIconUrl, uroboroSQLIconUrl, uroboroSQLIconUrl],
+ url: "https://future-architect.github.io/uroborosql-doc/",
+ },
+ {
+ label: "Urushi",
+ iconSrc: [urushiIconUrl, urushiIconUrl],
+ url: "http://future-architect.github.io/urushi/",
+ },
+ {
+ label: "Awesome OSS",
+ iconSrc: [vulsIconUrl, uroboroSQLIconUrl, urushiIconUrl],
+ url: "https://future-architect.github.io/",
+ },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
+ ← + + Theme + + Define Cell Messages + + → +
# Define Column Styles
# Standard Column Style
Define column style by using style
property.
Properties below are prepared in standard.
Property | Description |
---|---|
color | Define the color of cell. |
textAlign | Define the horizontal position of text in cell. |
textBaseline | Define the vertical position of text in cell. |
bgColor | Define the background color of cell. |
font | Define the font of cell. |
padding | Define the padding of cell. If you set 4 values separately, please set the Array . |
textOverflow | Define how to display when text overflows the area of a cell. clip or ellipsis is available. |
visibility | Specifying hidden to it will stop drawing the cell's content. Note that this does not stop the cell's action. |
Note that the column type may add style properties that you can use. The properties added are described in the documentation for each column type.
<div class="sample1 demo-grid small"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ { field: "no", caption: "no", width: 50 },
+
+ // default
+ { field: "text", caption: "default", width: 150 },
+
+ // color
+ { field: "text", caption: "color", width: 150, style: { color: "red" } },
+ // textAlign
+ {
+ field: "text",
+ caption: "right",
+ width: 150,
+ style: { textAlign: "right" },
+ },
+ {
+ field: "text",
+ caption: "center",
+ width: 150,
+ style: { textAlign: "center" },
+ },
+ // textBaseline
+ {
+ field: "text",
+ caption: "top",
+ width: 150,
+ style: { textBaseline: "top" },
+ },
+ {
+ field: "text",
+ caption: "bottom",
+ width: 150,
+ style: { textBaseline: "bottom" },
+ },
+
+ // bgColor
+ {
+ field: "text",
+ caption: "bgColor",
+ width: 150,
+ style: { bgColor: "#5f5" },
+ },
+
+ // font
+ {
+ field: "text",
+ caption: "font",
+ width: 150,
+ style: { font: "9px sans-serif" },
+ },
+ ],
+});
+grid.records = [
+ { no: 1, text: "sample text" },
+ { no: 2, text: "sample text" },
+ { no: 3, text: "sample text" },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<div class="sample2 demo-grid middle"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample2"),
+ header: [
+ { field: "no", caption: "no", width: 50 },
+
+ // default
+ { field: "text", caption: "default", width: 150 },
+
+ // padding
+ { field: "text", caption: "padding", width: 150, style: { padding: 20 } },
+ {
+ field: "text",
+ caption: "padding",
+ width: 150,
+ style: { padding: [0 /*top*/, 10 /*right*/, 15 /*bottom*/, 20 /*left*/] },
+ },
+
+ //{{#if_v '0.6.0'}} textOverflow
+ {
+ field: "longText",
+ caption: "textOverflow",
+ width: 150,
+ style: { textOverflow: "ellipsis" },
+ },
+ //{{/if_v }}
+ ],
+ defaultRowHeight: 80,
+ headerRowHeight: 24,
+});
+grid.records = [
+ {
+ no: 1,
+ text: "sample text",
+ longText: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
+ },
+ {
+ no: 2,
+ text: "sample text",
+ longText: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
+ },
+ {
+ no: 3,
+ text: "sample text",
+ longText: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
+ },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Advanced Column Style
style
property can be used by the advanced ways below.
- change style by each record
This can be done by functions below.
- use the function
- use the instance of Style class
<div class="sample3 demo-grid small"></div>
+<label>change background color of text</label>
+<select class="sample3theme">
+ <option value="" selected="true">default</option>
+ <option value="red">red</option>
+ <option value="#DFF">#DFF</option>
+</select>
+
2
3
4
5
6
7
const textFieldStyle = new cheetahGrid.columns.style.Style();
+const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample3"),
+ header: [
+ { field: "no", caption: "no", width: 50 },
+
+ {
+ field: "value",
+ caption: "value",
+ width: 150,
+ columnType: "number",
+ //function
+ style(rec) {
+ return {
+ color: rec.value <= 0 ? "red" : undefined,
+ };
+ },
+ },
+
+ {
+ field: "text",
+ caption: "text",
+ width: 150,
+ //Style instance
+ style: textFieldStyle,
+ },
+ ],
+});
+grid.records = [
+ { no: 1, text: "sample text", value: 100 },
+ { no: 2, text: "sample text", value: 50 },
+ { no: 3, text: "sample text", value: 0 },
+ { no: 4, text: "sample text", value: -50 },
+];
+
+const themeSelect = document.querySelector(".sample3theme");
+themeSelect.onchange = function () {
+ //change bg color
+ if (themeSelect.value === "default") {
+ textFieldStyle.bgColor = null;
+ } else {
+ textFieldStyle.bgColor = themeSelect.value;
+ }
+};
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Header Style
Define column header style by using headerStyle
property.
<div class="sample4 demo-grid small"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample4"),
+ header: [
+ { field: "no", caption: "no", width: 50 },
+
+ // default
+ { field: "text", caption: "default", width: 150 },
+
+ // color
+ {
+ field: "text",
+ caption: "color",
+ width: 150,
+ headerStyle: { color: "red" },
+ },
+ // textAlign
+ {
+ field: "text",
+ caption: "center",
+ width: 150,
+ headerStyle: { textAlign: "center" },
+ },
+ // textBaseline
+ {
+ field: "text",
+ caption: "bottom",
+ width: 150,
+ headerStyle: { textBaseline: "bottom" },
+ },
+ // bgColor
+ {
+ field: "text",
+ caption: "bgColor",
+ width: 150,
+ headerStyle: { bgColor: "#5f5" },
+ },
+ // font
+ {
+ field: "text",
+ caption: "font",
+ width: 150,
+ headerStyle: { font: "9px sans-serif" },
+ },
+ // textOverflow
+ {
+ field: "text",
+ caption: "textOverflow clip",
+ width: 150,
+ headerStyle: { textOverflow: "clip" },
+ },
+ {
+ field: "text",
+ caption: "textOverflow ellipsis",
+ width: 150,
+ headerStyle: {
+ textOverflow: "ellipsis" /*In the header this is the default*/,
+ },
+ },
+ ],
+});
+grid.records = [
+ { no: 1, text: "data" },
+ { no: 2, text: "data" },
+ { no: 3, text: "data" },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
+ ← + + Define Column Types + + Indicators + + → +
# Indicators
You can use the style property to display the indicators.
+Currently the only indicator style supported is "triangle"
.
# Usage
<div class="sample-basic demo-grid small"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample-basic"),
+ header: [
+ {
+ field: "no",
+ caption: "No",
+ width: 50,
+ },
+ {
+ field: "text",
+ caption: "Text",
+ width: 150,
+ style: { indicatorTopLeft: "triangle" },
+ },
+ {
+ field: "text",
+ caption: "Text",
+ width: 150,
+ style: { indicatorTopRight: "triangle" },
+ },
+ ],
+});
+grid.records = [
+ { no: 1, text: "data" },
+ { no: 2, text: "data" },
+ { no: 3, text: "data" },
+ { no: 4, text: "data" },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
It supports indicatorTopLeft
, indicatorTopRight
, indicatorBottomRight
, and indicatorBottomLeft
You can also control the display of indicators per record using functions.
<div class="sample-function demo-grid small"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample-function"),
+ header: [
+ {
+ field: "no",
+ caption: "No",
+ width: 50,
+ },
+ {
+ field: "text",
+ caption: "Text",
+ width: 150,
+ style(record) {
+ if (record.no === 1) {
+ return { indicatorTopLeft: "triangle" };
+ }
+ if (record.no === 2) {
+ return { indicatorTopRight: "triangle" };
+ }
+ if (record.no === 3) {
+ return { indicatorBottomRight: "triangle" };
+ }
+ if (record.no === 4) {
+ return { indicatorBottomLeft: "triangle" };
+ }
+ return undefined;
+ },
+ },
+ ],
+});
+grid.records = [
+ { no: 1, text: "data" },
+ { no: 2, text: "data" },
+ { no: 3, text: "data" },
+ { no: 4, text: "data" },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Indicator Styles
We recommend using themes to control the style of the indicator.
+You can control the size and color of the indicators by setting the theme's indicators.topLeftColor
, indicators.topLeftSize
, indicators.topRightColor
, indicators.topRightSize
, indicators.bottomRightColor
, indicators.bottomRightSize
, indicators.bottomLeftColor
, and indicators.bottomLeftSize
properties.
<div class="sample-theme demo-grid small"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample-theme"),
+ header: [
+ {
+ field: "no",
+ caption: "No",
+ width: 50,
+ },
+ {
+ field: "text",
+ caption: "Text",
+ width: 150,
+ style(record) {
+ if (record.no === 1) {
+ return { indicatorTopLeft: "triangle" };
+ }
+ if (record.no === 2) {
+ return { indicatorTopRight: "triangle" };
+ }
+ if (record.no === 3) {
+ return { indicatorBottomRight: "triangle" };
+ }
+ if (record.no === 4) {
+ return { indicatorBottomLeft: "triangle" };
+ }
+ return undefined;
+ },
+ },
+ ],
+});
+grid.records = [
+ { no: 1, text: "data" },
+ { no: 2, text: "data" },
+ { no: 3, text: "data" },
+ { no: 4, text: "data" },
+];
+grid.theme = {
+ indicators: {
+ topLeftColor: "blue",
+ topLeftSize: 10,
+ topRightColor: "red",
+ topRightSize: 10,
+ bottomRightColor: "green",
+ bottomRightSize: 10,
+ bottomLeftColor: "black",
+ bottomLeftSize: 10,
+ },
+};
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
You can also specify the indicator in object form if you want to change its style individually.
<div class="sample-style demo-grid small"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample-style"),
+ header: [
+ {
+ field: "no",
+ caption: "No",
+ width: 50,
+ },
+ {
+ field: "text",
+ caption: "Text",
+ width: 150,
+ style(record) {
+ if (record.no === 3) {
+ return {
+ indicatorTopLeft: {
+ style: "triangle",
+ color: "red",
+ size: 15,
+ },
+ };
+ }
+ return undefined;
+ },
+ },
+ ],
+});
+grid.records = [
+ { no: 1, text: "data" },
+ { no: 2, text: "data" },
+ { no: 3, text: "data" },
+ { no: 4, text: "data" },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
+ ← + + Define Column Styles + + Define Column Actions + + → +
# BranchGraphColumn
Show branch graph.
# Constructor Properties
Property | Description | Default |
---|---|---|
start | Set the moving direction by setting the beggining point. 'top' or 'bottom' | 'bottom' |
cache | Set true when caching the calculation result of the branch structure. Please call clearCache(grid) when deleting the cahced data. | false |
# Style Properties
Property | Description | Default |
---|---|---|
branchColors | Set the function which returns the color of branch you want to use. arguments: (branch name, index ) | the function which returns following colors in turn. '#979797' ,'#008fb5' ,'#f1c109' |
margin | Set the margin of side. | 4 |
circleSize | Set the size of point which express commit . | 16 |
branchLineWidth | Set the width of branch lines. | 4 |
mergeStyle | Set the way to express the merge line. 'bezier' or 'straight' | 'bezier' |
<div class="sample1 demo-grid large"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ {
+ field: (rec) => rec,
+ caption: "BranchGraph",
+ width: 200,
+ columnType: new cheetahGrid.columns.type.BranchGraphColumn({
+ start: "top", // Specify the start and indicate the direction to proceed. 'top' or 'bottom'. default 'bottom'
+ cache: false, // cache enable. default false
+ }),
+ },
+ {
+ field(rec) {
+ return `${JSON.stringify(rec)},`;
+ },
+ caption: "command",
+ width: 1000,
+ },
+ ],
+ frozenColCount: 1,
+});
+grid.records = [
+ [
+ // new branch 'mastar'
+ {
+ command: "branch",
+ branch: "mastar",
+ },
+ // and commit 'mastar' branch
+ {
+ command: "commit",
+ branch: "mastar",
+ },
+ ],
+ [
+ // commit 'mastar' branch
+ {
+ command: "commit",
+ branch: "mastar",
+ },
+ ],
+ [
+ // new branch 'develop'. from 'mastar'
+ {
+ command: "branch",
+ branch: {
+ from: "mastar",
+ to: "develop",
+ },
+ },
+ ],
+ [
+ // commit 'develop' branch
+ {
+ command: "commit",
+ branch: "develop",
+ },
+ ],
+ [
+ // merge 'develop' branch into 'master' branch
+ {
+ command: "merge",
+ branch: {
+ from: "develop",
+ to: "mastar",
+ },
+ },
+ // and tag with v.0.0.1
+ {
+ command: "tag",
+ branch: "mastar",
+ tag: "v1.0.0",
+ },
+ ],
+ [
+ null, // not doing
+ ],
+ //-------------------------
+ [
+ {
+ command: "branch",
+ branch: {
+ from: "develop",
+ to: "develop2",
+ },
+ },
+ {
+ command: "commit",
+ branch: "develop2",
+ },
+ ],
+ [
+ {
+ command: "branch",
+ branch: {
+ from: "develop",
+ to: "develop3",
+ },
+ },
+ {
+ command: "commit",
+ branch: "develop3",
+ },
+ {
+ command: "merge",
+ branch: {
+ from: "develop2",
+ to: "mastar",
+ },
+ },
+ ],
+ [
+ {
+ command: "commit",
+ branch: "develop2",
+ },
+ ],
+ [
+ {
+ command: "branch",
+ branch: {
+ from: "develop2",
+ to: "develop4",
+ },
+ },
+ {
+ command: "commit",
+ branch: "develop4",
+ },
+ {
+ command: "branch",
+ branch: {
+ from: "develop2",
+ to: "develop5",
+ },
+ },
+ {
+ command: "commit",
+ branch: "develop5",
+ },
+ ],
+ [
+ {
+ command: "commit",
+ branch: "develop2",
+ },
+ ],
+ [
+ {
+ command: "tag",
+ branch: "mastar",
+ tag: "v1.1.0",
+ },
+ {
+ command: "commit",
+ branch: "mastar",
+ },
+ {
+ command: "commit",
+ branch: "develop4",
+ },
+ ],
+ {
+ command: "commit",
+ branch: "develop3",
+ },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
+ ← + + MultilineTextColumn + + RadioColumn + + → +
# ButtonColumn
Show the button.
# Constructor Properties
Property | Description |
---|---|
caption | Define button caption. |
# Style Properties
Property | Description | Default |
---|---|---|
buttonBgColor | Define background color of button. | Resolve by the theme. |
In addition to this, the Standard styles is available.
<div class="sample1 demo-grid small"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ {
+ caption: "Button1",
+ width: 180,
+ columnType: new cheetahGrid.columns.type.ButtonColumn({
+ caption: "FIXED LABEL",
+ }),
+ action: new cheetahGrid.columns.action.ButtonAction({
+ action(rec) {
+ alert(JSON.stringify(rec));
+ },
+ }),
+ },
+
+ {
+ caption: "Button2",
+ field: "buttonCaption", // Get caption of button from record
+ width: 180,
+ columnType: "button",
+ action: new cheetahGrid.columns.action.ButtonAction({
+ action(rec) {
+ alert(JSON.stringify(rec));
+ },
+ }),
+ },
+ ],
+});
+grid.records = [
+ { buttonCaption: "BUTTON1" },
+ { buttonCaption: "BUTTON2" },
+ { buttonCaption: "BUTTON3" },
+ { buttonCaption: "BUTTON4" },
+ { buttonCaption: "BUTTON5" },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+ ← + + MenuColumn + + ImageColumn + + → +
# CheckColumn
Show the checkbox.
To make it editable, please use CheckEditor.
# Style Properties
Property | Description | Default |
---|---|---|
checkBgColor | Define background color of checkbox, when it is checked. | Resolve by the theme. |
uncheckBgColor | Define background color of checkbox, when it is unchecked. | Resolve by the theme. |
borderColor | Define border color of checkbox. | Resolve by the theme. |
textAlign | Define horizontal position of checkbox in cell. | 'center' |
textBaseline | Define vertical position of checkbox in cell. | -- |
bgColor | Define background color of cell. | Resolve by the theme. |
<div class="sample1 demo-grid small"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ {
+ field: "c1",
+ caption: "check",
+ width: 100,
+ columnType: "check", // or `new cheetahGrid.columns.type.CheckColumn()`
+ },
+ {
+ field: "c2",
+ caption: "style",
+ width: 100,
+ columnType: "check",
+ style: {
+ uncheckBgColor: "#FDD",
+ checkBgColor: "rgb(255, 73, 72)",
+ borderColor: "red",
+ },
+ },
+ {
+ caption: "show",
+ width: 100,
+ columnType: new cheetahGrid.columns.type.ButtonColumn({
+ caption: "SHOW",
+ }),
+ action: new cheetahGrid.columns.action.ButtonAction({
+ action(rec) {
+ alert(JSON.stringify(rec, null, " "));
+ },
+ }),
+ },
+ ],
+});
+grid.records = [
+ { c1: true, c2: false },
+ { c1: false, c2: true },
+ { c1: true, c2: false },
+ { c1: false, c2: true },
+ { c1: true, c2: false },
+ { c1: false, c2: true },
+ { c1: true, c2: false },
+ { c1: false, c2: true },
+ { c1: true, c2: false },
+ { c1: false, c2: true },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
+ ← + + NumberColumn + + MenuColumn + + → +
# Column Type Classes
# Namespace cheetahGrid.columns.type
Class Name | Function | Others | Related Links |
---|---|---|---|
Column | show text | same as not specify type | --- |
NumberColumn | show number with comma-separated | same as columnType: 'number' | NumberColumn |
CheckColumn | show checkbox | same as columnType: 'check' | - CheckColumn - CheckEditor |
MenuColumn | show menu | --- | - MenuColumn - InlineMenuEditor |
ButtonColumn | show button | columnType: 'button' has same the function | - ButtonColumn - ButtonAction |
ImageColumn | show image | same as columnType: 'image' | ImageColumn |
PercentCompleteBarColumn | show percent complete bar | --- | PercentCompleteBarColumn |
IconColumn | show icon only | --- | IconColumn |
MultilineTextColumn | show multiline text | same as columnType: 'multilinetext' | MultilineTextColumn |
BranchGraphColumn | show branch graph | --- | BranchGraphColumn |
RadioColumn | show radio button | same as columnType: 'radio' | - RadioColumn - RadioEditor |
+ ← + + Define Column Types + + NumberColumn + + → +
# IconColumn
Show ICON using Web Font.
+Number of ICONs can be set at field.
TIP
When showing ICON to ordinal column, please refer to here
<div class="sample1 demo-grid small"></div>
+
ICON in sample uses Material icons (opens new window)
<!-- Material Icons: https://material.io/icons/ --> +<link + rel="stylesheet" + type="text/css" + href="https://fonts.googleapis.com/icon?family=Material+Icons" +/> +
1
2
3
4
5
6
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ {
+ field: "value",
+ caption: "value",
+ width: 100,
+ },
+ {
+ field: "value",
+ caption: "icon",
+ width: 130,
+ columnType: new cheetahGrid.columns.type.IconColumn({
+ className: "material-icons",
+ content: "\uE885", // https://material.io/icons/#ic_grade
+ }),
+ style: {
+ color: "gold",
+ },
+ },
+ ],
+});
+grid.records = [
+ { value: 1 },
+ { value: 2 },
+ { value: 3 },
+ { value: 4 },
+ { value: 5 },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+ ← + + PercentCompleteBarColumn + + MultilineTextColumn + + → +
# ImageColumn
# Draw image
Use columnType: 'image'
to draw image in the cell.
<div class="sample1 demo-grid middle"></div>
+
note: Images used in samples are on wikipedia (opens new window). +Please click the images to check details of those.
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ {
+ field: "imageUrl",
+ caption: "image",
+ width: 100,
+ columnType: "image",
+ style: { imageSizing: "keep-aspect-ratio" },
+
+ // open image detail
+ action: new cheetahGrid.columns.action.Action({
+ action(rec) {
+ window.open(rec.link, "_blank");
+ },
+ }),
+ },
+ { field: "label", caption: "label", width: 200 },
+ ],
+ frozenColCount: 1,
+ defaultRowHeight: 100,
+ headerRowHeight: 24,
+});
+//https://en.wikipedia.org/wiki/Cheetah
+grid.records = [
+ {
+ imageUrl:
+ "https://upload.wikimedia.org/wikipedia/commons/thumb/a/ab/Kooshki_%28Iranian_Cheetah%29_03.jpg/440px-Kooshki_%28Iranian_Cheetah%29_03.jpg",
+ label: "Asiatic cheetah",
+ link: "https://en.wikipedia.org/wiki/File:Kooshki_(Iranian_Cheetah)_03.jpg",
+ },
+ {
+ imageUrl:
+ "https://upload.wikimedia.org/wikipedia/commons/thumb/6/68/Cheetah_%28Kruger_National_Park%2C_South_Africa%2C_2001%29.jpg/180px-Cheetah_%28Kruger_National_Park%2C_South_Africa%2C_2001%29.jpg",
+ label: "South African cheetah",
+ link: "https://en.wikipedia.org/wiki/File:Cheetah_(Kruger_National_Park,_South_Africa,_2001).jpg",
+ },
+ {
+ imageUrl:
+ "https://upload.wikimedia.org/wikipedia/commons/thumb/5/55/Cheetah_at_Whipsnade_Zoo%2C_Dunstable.jpg/180px-Cheetah_at_Whipsnade_Zoo%2C_Dunstable.jpg",
+ label: "Sudan cheetah",
+ link: "https://en.wikipedia.org/wiki/File:Cheetah_at_Whipsnade_Zoo,_Dunstable.jpg",
+ },
+ {
+ imageUrl:
+ "https://upload.wikimedia.org/wikipedia/commons/thumb/6/6f/TanzanianCheetah.jpg/180px-TanzanianCheetah.jpg",
+ label: "Tanzanian cheetah",
+ link: "https://en.wikipedia.org/wiki/File:TanzanianCheetah.jpg",
+ },
+ {
+ imageUrl:
+ "https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Cheetah_portrait_Whipsnade_Zoo.jpg/220px-Cheetah_portrait_Whipsnade_Zoo.jpg",
+ label: "Cheetah",
+ link: "https://en.wikipedia.org/wiki/File:Cheetah_portrait_Whipsnade_Zoo.jpg",
+ },
+ {
+ imageUrl:
+ "https://upload.wikimedia.org/wikipedia/commons/thumb/5/5e/King_cheetah.jpg/170px-King_cheetah.jpg",
+ label: "King cheetah",
+ link: "https://en.wikipedia.org/wiki/File:King_cheetah.jpg",
+ },
+];
+grid.configure("fadeinWhenCallbackInPromise", true);
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
+ ← + + ButtonColumn + + PercentCompleteBarColumn + + → +
# MenuColumn
Maps from value
to label
and display it.
To make it editable, please use InlineMenuEditor.
# Constructor Properties
Property | Description |
---|---|
options | Define mapping options. |
# Style Properties
Property | Description | Default |
---|---|---|
appearance | Defines whether to display a dropdown arrow. (you can set 'menulist-button' or 'none' ) | 'menulist-button' |
In addition to this, Standard styles is available.
<div class="sample1 demo-grid small"></div>
+
const options = [
+ { value: "", label: "Empty" },
+ { value: "1", label: "Option 1" },
+ { value: "2", label: "Option 2" },
+ { value: "3", label: "Option 3" },
+ { value: "4", label: "Option 4" },
+ { value: "5", label: "Option 5" },
+ { value: "6", label: "Option 6" },
+ { value: "7", label: "Option 7" },
+];
+const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ {
+ field: "sel",
+ caption: "MenuColumn",
+ width: 260,
+ columnType: new cheetahGrid.columns.type.MenuColumn({ options }),
+ },
+ {
+ field: "sel2",
+ caption: "style",
+ width: 260,
+ columnType: new cheetahGrid.columns.type.MenuColumn({ options }),
+ style: { appearance: "none" },
+ },
+
+ {
+ caption: "show",
+ width: 100,
+ columnType: new cheetahGrid.columns.type.ButtonColumn({
+ caption: "SHOW",
+ }),
+ action: new cheetahGrid.columns.action.ButtonAction({
+ action(rec) {
+ alert(JSON.stringify(rec, null, " "));
+ },
+ }),
+ },
+ ],
+});
+grid.records = [
+ { sel: "", sel2: "" },
+ { sel: "1", sel2: "1" },
+ { sel: "2", sel2: "2" },
+ { sel: "3", sel2: "3" },
+ { sel: "", sel2: "" },
+ { sel: "1", sel2: "1" },
+ { sel: "2", sel2: "2" },
+ { sel: "3", sel2: "3" },
+ { sel: "", sel2: "" },
+ { sel: "1", sel2: "1" },
+ { sel: "2", sel2: "2" },
+ { sel: "3", sel2: "3" },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
+ ← + + CheckColumn + + ButtonColumn + + → +
# MultilineTextColumn
Show multiline text.
By specifying multilinetext
for the columnType
property,
+You can display multiple lines of text in a cell.
# Style Properties
Property | Description | Default |
---|---|---|
lineHeight | Define the amount of space used for lines | -- |
autoWrapText | Define whether to wrap automatically. | -- |
lineClamp | Define truncates text at a specific number of lines. | -- |
In addition to this, the Standard styles is available.
<div class="sample1 demo-grid middle"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ {
+ field: "title",
+ caption: "title",
+ width: 150,
+ },
+ {
+ field: "description",
+ caption: "description",
+ width: "calc(100% - 150px)",
+ columnType: "multilinetext",
+ },
+ ],
+ frozenColCount: 1,
+ defaultRowHeight: 100,
+ headerRowHeight: 40,
+});
+grid.records = [
+ {
+ title: "Lorem ipsum",
+ description: `Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
+Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.`,
+ },
+ {
+ title: "multilinetext",
+ description: `By specifying 'multilinetext' for the 'columnType' property,
+You can display multiple lines of text in a cell.`,
+ },
+ {
+ title: "multilinetext",
+ description: `プロパティ'columnType'に'multilinetext'を指定することで、
+セルに複数行テキストを表示することができます。 `,
+ },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Aligns
<div class="sample2 demo-grid large"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample2"),
+ header: [
+ {
+ field: "title",
+ caption: "title",
+ width: 150,
+ },
+ //textAlign
+ {
+ field: "description",
+ caption: "left",
+ width: 1000,
+ columnType: "multilinetext",
+ style: { textAlign: "left" },
+ },
+ {
+ field: "description",
+ caption: "right",
+ width: 1000,
+ columnType: "multilinetext",
+ style: { textAlign: "right" },
+ },
+ {
+ field: "description",
+ caption: "center",
+ width: 1000,
+ columnType: "multilinetext",
+ style: { textAlign: "center" },
+ },
+ //textBaseline
+ {
+ field: "description",
+ caption: "top",
+ width: 1000,
+ columnType: "multilinetext",
+ style: { textBaseline: "top" },
+ },
+ {
+ field: "description",
+ caption: "middle",
+ width: 1000,
+ columnType: "multilinetext",
+ style: { textBaseline: "middle" },
+ },
+ {
+ field: "description",
+ caption: "bottom",
+ width: 1000,
+ columnType: "multilinetext",
+ style: { textBaseline: "bottom" },
+ },
+ ],
+ frozenColCount: 1,
+ defaultRowHeight: 200,
+ headerRowHeight: 40,
+});
+grid.records = vm.records;
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# lineHeight
<div class="sample3 demo-grid large"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample3"),
+ header: [
+ {
+ field: "title",
+ caption: "title",
+ width: 150,
+ },
+ {
+ field: "description",
+ caption: "lineHeight=3em top",
+ width: 1000,
+ columnType: "multilinetext",
+ style: {
+ lineHeight: "3em",
+ textBaseline: "top",
+ },
+ },
+ {
+ field: "description",
+ caption: "lineHeight=3em middle",
+ width: 1000,
+ columnType: "multilinetext",
+ style: {
+ lineHeight: "3em",
+ textBaseline: "middle",
+ },
+ },
+ {
+ field: "description",
+ caption: "lineHeight=3em bottom",
+ width: 1000,
+ columnType: "multilinetext",
+ style: {
+ lineHeight: "3em",
+ textBaseline: "bottom",
+ },
+ },
+ ],
+ frozenColCount: 1,
+ defaultRowHeight: 300,
+ headerRowHeight: 40,
+});
+grid.records = vm.records;
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# autoWrapText
<div class="sample4 demo-grid large"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample4"),
+ header: [
+ {
+ field: "title",
+ caption: "title",
+ width: 150,
+ },
+ {
+ field: "description",
+ caption: "autoWrapText=true",
+ width: 600,
+ columnType: "multilinetext",
+ style: {
+ autoWrapText: true,
+ },
+ },
+ ],
+ frozenColCount: 1,
+ defaultRowHeight: 100,
+ headerRowHeight: 40,
+});
+grid.records = vm.records;
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# lineClamp
<div class="sample5 demo-grid middle"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample5"),
+ header: [
+ {
+ field: "title",
+ caption: "title",
+ width: 150,
+ },
+ {
+ field: "description",
+ caption: "lineClamp=2 autoWrapText=true",
+ width: 600,
+ columnType: "multilinetext",
+ style: {
+ autoWrapText: true,
+ lineClamp: 2,
+ },
+ },
+ {
+ field: "description",
+ caption: 'lineClamp="auto" autoWrapText=true',
+ width: 600,
+ columnType: "multilinetext",
+ style: {
+ autoWrapText: true,
+ lineClamp: "auto",
+ },
+ },
+ {
+ field: "description",
+ caption: "lineClamp=2 textOverflow=ellipsis",
+ width: 600,
+ columnType: "multilinetext",
+ style: {
+ lineClamp: 2,
+ textOverflow: "ellipsis",
+ },
+ },
+ ],
+ frozenColCount: 1,
+ defaultRowHeight: 60,
+ headerRowHeight: 40,
+});
+grid.records = vm.records;
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
+ ← + + IconColumn + + BranchGraphColumn + + → +
# NumberColumn
Show formatted numbers.
Format number with the style defined at format
property in constructor.
+Please define the instance of Intl.NumberFormat
class at format
property.
If property isn't defined, format number using the instance created by new Intl.NumberFormat()
automatically.
+Which means format style completely depends on Intl.NumberFormat
.
In addition, this column type behave same as columnType: 'number'
.
# Constructor Properties
Property | Description |
---|---|
format | Define number format. |
# Style Properties
Standard styles is available.
<div class="sample1 demo-grid small"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ {
+ field: "value",
+ caption: "text",
+ width: 180,
+ },
+ {
+ field: "value",
+ caption: "default",
+ width: 180,
+ columnType: new cheetahGrid.columns.type.NumberColumn(),
+ },
+ {
+ field: "value",
+ caption: "columnType: number",
+ width: 180,
+ columnType: "number",
+ },
+ {
+ field: "value",
+ caption: "JPY",
+ width: 180,
+ columnType: new cheetahGrid.columns.type.NumberColumn({
+ format: new Intl.NumberFormat("ja-JP", {
+ style: "currency",
+ currency: "JPY",
+ }),
+ }),
+ },
+ {
+ field: "value",
+ caption: "USD",
+ width: 180,
+ columnType: new cheetahGrid.columns.type.NumberColumn({
+ format: new Intl.NumberFormat("en-US", {
+ style: "currency",
+ currency: "USD",
+ }),
+ }),
+ },
+ {
+ field: "value",
+ caption: "EUR",
+ width: 180,
+ columnType: new cheetahGrid.columns.type.NumberColumn({
+ format: new Intl.NumberFormat("de-DE", {
+ style: "currency",
+ currency: "EUR",
+ }),
+ }),
+ },
+ ],
+});
+grid.records = [
+ { value: 1234567890 },
+ { value: 1234567890.12 },
+ { value: -1234567890.123 },
+ { value: -1234567890.123456 },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
+ ← + + Column Type Classes + + CheckColumn + + → +
# PercentCompleteBarColumn
Show the percent complete bar.
# Constructor Properties
Property | Description |
---|---|
min | Defines the minimum value of the bar. |
max | Defines the maximum value of the bar. |
formatter | Define the value display format. |
# Style Properties
Property | Description | Default |
---|---|---|
barColor | Define color of bar. you can set a function that returns color from the value. | -- |
barBgColor | Define background color of bar. | -- |
barHeight | Define height of bar. | -- |
In addition to this, the Standard styles is available.
<div class="sample1 demo-grid middle"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ { field: "percent", caption: "label", width: 100 },
+ {
+ field: "percent",
+ caption: "percent",
+ width: 200,
+ columnType: new cheetahGrid.columns.type.PercentCompleteBarColumn(),
+ },
+ {
+ field: "value",
+ caption: "value(10-20)",
+ width: 200,
+ columnType: new cheetahGrid.columns.type.PercentCompleteBarColumn({
+ min: 10,
+ max: 20,
+ }),
+ },
+ {
+ field: "value",
+ caption: "value(format)",
+ width: 200,
+ columnType: new cheetahGrid.columns.type.PercentCompleteBarColumn({
+ min: 10,
+ max: 20,
+ formatter: (v) => `${v}pt`,
+ }),
+ },
+ {
+ field: "percent",
+ caption: "percent2",
+ width: 200,
+ columnType: new cheetahGrid.columns.type.PercentCompleteBarColumn({
+ formatter: (s) => "",
+ }),
+ style: {
+ barHeight: 19,
+ },
+ },
+ {
+ field: "percent",
+ caption: "percent3",
+ width: 200,
+ columnType: new cheetahGrid.columns.type.PercentCompleteBarColumn(),
+ style: {
+ barBgColor: "#aaa",
+ barColor: "#444",
+ },
+ },
+ {
+ field: "percent",
+ caption: "percent4",
+ width: 200,
+ columnType: new cheetahGrid.columns.type.PercentCompleteBarColumn(),
+ style: {
+ barBgColor: (per) => (per > 50 ? "#faa" : "#aaa"),
+ barColor: (per) => (per > 50 ? "#f44" : "#444"),
+ },
+ },
+ ],
+ frozenColCount: 1,
+});
+grid.records = [
+ { percent: "100%", value: 20 },
+ { percent: "80%", value: 18 },
+ { percent: "60%", value: 16 },
+ { percent: "40%", value: 14 },
+ { percent: "20%", value: 12 },
+ { percent: "0%", value: 10 },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
+ ← + + ImageColumn + + IconColumn + + → +
# RadioColumn
Show the radio button.
To make it editable, please use RadioEditor.
# Style Properties
Property | Description | Default |
---|---|---|
checkColor | Define check mark color of radio button. | resolve by the theme. |
checkBgColor | Define background color of radio button, when it is checked. | resolve by the theme. |
uncheckBgColor | Define background color of radio button, when it is unchecked. | resolve by the theme. |
checkBorderColor | Define border color of radio button, when it is checked. | resolve by the theme. |
uncheckBorderColor | Define border color of radio button, when it is unchecked. | resolve by the theme. |
textAlign | Define horizontal position of radio button in cell. | 'center' |
textBaseline | Define vertical position of radio button in cell. | -- |
bgColor | Define background color of cell. | resolve by the theme. |
<div class="sample1 demo-grid small"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ {
+ field: "c1",
+ caption: "radio",
+ width: 100,
+ columnType: "radio", // or `new cheetahGrid.columns.type.RadioColumn()`
+ },
+ {
+ field: "c2",
+ caption: "style",
+ width: 100,
+ columnType: "radio",
+ style: {
+ checkColor: "rgb(255, 73, 72)",
+ checkBgColor: "#FDD",
+ checkBorderColor: "red",
+ uncheckBgColor: "#DDF",
+ uncheckBorderColor: "rgb(72, 73, 255)",
+ },
+ },
+ {
+ caption: "show",
+ width: 100,
+ columnType: new cheetahGrid.columns.type.ButtonColumn({
+ caption: "SHOW",
+ }),
+ action: new cheetahGrid.columns.action.ButtonAction({
+ action(rec) {
+ alert(JSON.stringify(rec, null, " "));
+ },
+ }),
+ },
+ ],
+});
+grid.records = [
+ { c1: true, c2: false },
+ { c1: false, c2: true },
+ { c1: true, c2: false },
+ { c1: false, c2: true },
+ { c1: true, c2: false },
+ { c1: false, c2: true },
+ { c1: true, c2: false },
+ { c1: false, c2: true },
+ { c1: true, c2: false },
+ { c1: false, c2: true },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
+ ← + + BranchGraphColumn + + Define Column Styles + + → +
# Define Column Types
# Standard Column Type
Set the column type by using columnType
.
property | description | LINK |
---|---|---|
none | draw text in the cell | --- |
'number' | draw number in the cell with comma-separated | NumberColumn |
'check' | draw checkbox in the cell | CheckColumn |
'button' | draw button in the cell | ButtonColumn |
'image' | draw image in the cell | ImageColumn |
'multilinetext' | draw multiline text in the cell | MultilineTextColumn |
'radio' | draw radio button in the cell | RadioColumn |
<div class="sample1 demo-grid small"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ { field: "no", caption: "no", width: 50 },
+
+ //default
+ { field: "default", caption: "default", width: 150 },
+ ],
+});
+grid.records = [
+ { no: 1, default: "sample text" },
+ { no: 2, default: "sample text" },
+ { no: 3, default: "sample text" },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
<div class="sample2 demo-grid small"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample2"),
+ header: [
+ { field: "no", caption: "no", width: 50 },
+
+ { field: "number", caption: "number", width: 180, columnType: "number" },
+ {
+ field: "check",
+ caption: "check",
+ width: 50,
+ columnType: "check",
+ action: "check",
+ },
+ {
+ caption: "button",
+ width: 100,
+ columnType: new cheetahGrid.columns.type.ButtonColumn({
+ caption: "show rec",
+ }),
+ action: new cheetahGrid.columns.action.ButtonAction({
+ action(rec) {
+ alert(JSON.stringify(rec));
+ },
+ }),
+ },
+ ],
+});
+grid.records = [
+ { no: 1, number: 12345, check: true },
+ { no: 2, number: 67890, check: false },
+ { no: 3, number: 1234567890.098, check: true },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Advanced Column Type
You can try kinds of view type by defining columnType
property using the instance.
Please refer to here
+ ← + + Define Column Width + + Column Type Classes + + → +
# Define Column Width
You can set the width of each column by using width
property.
+If nothing is set to width
property, the value of defaultColWidth
(property in grid
) is used.
You can use %
, calc()
or auto
by setting a string to the width
property.
You can also set the minimum and maximum widths by setting the minWidth
and maxWidth
properties.
<div class="sample1 demo-grid middle"></div>
+
const records = generatePersons(100);
+
+const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ {
+ field: "check",
+ caption: "",
+ columnType: "check",
+ action: "check",
+ minWidth: 50,
+ maxWidth: 50,
+ },
+ {
+ field: "personid",
+ caption: "ID",
+ width: "10%",
+ minWidth: "50px",
+ maxWidth: "50%",
+ },
+ { field: "fname", caption: "First Name", width: "auto", minWidth: "120px" },
+ { field: "lname", caption: "Last Name", width: "auto", minWidth: "120px" },
+ {
+ field: "email",
+ caption: "Email",
+ width: "calc(60% - 110px)",
+ minWidth: "120px",
+ },
+ ],
+ defaultColWidth: 50,
+});
+grid.records = records;
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Events
You can set an event listener using the listen(type, listener)
method.
Please get the event type from cheetahGrid.ListGrid.EVENT_TYPE
(opens new window).
<textarea class="log" style="width: 100%; height: 100px;">Event logs</textarea>
+<input class="include-mouse" type="checkbox" /><label
+ >Include mousemove,mouseenter,mouseleave in the log</label
+>
+<div class="sample1 demo-grid middle"></div>
+
2
3
4
5
const lang =
+ navigator.language || navigator.userLanguage || navigator.browserLanguage;
+const records = generatePersons(100);
+const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ {
+ field: "check",
+ caption: "",
+ width: 60,
+ columnType: "check",
+ action: "check",
+ },
+ { field: "personid", caption: "ID", width: 100 },
+ { field: "fname", caption: "First Name", width: 200, action: "input" },
+ { field: "lname", caption: "Last Name", width: 200, action: "input" },
+ { field: "email", caption: "Email", width: 250, action: "input" },
+ {
+ field(rec) {
+ return rec.birthday.toLocaleString(lang, {
+ year: "numeric",
+ month: "long",
+ day: "numeric",
+ });
+ },
+ caption: "birthday",
+ width: 500,
+ },
+ ],
+ frozenColCount: 1,
+ records,
+});
+
+const log = (typeName, args) => {
+ const el = document.querySelector(".log");
+ el.value += `\nEvent: ${typeName} , args (${args
+ .map(JSON.stringify)
+ .join(", ")})`;
+ el.value = el.value.trim();
+ el.scrollTop = el.scrollHeight;
+};
+
+const {
+ CLICK_CELL,
+ DBLCLICK_CELL,
+ DBLTAP_CELL,
+ MOUSEDOWN_CELL,
+ MOUSEUP_CELL,
+ SELECTED_CELL,
+ KEYDOWN,
+ MOUSEMOVE_CELL,
+ MOUSEENTER_CELL,
+ MOUSELEAVE_CELL,
+ MOUSEOVER_CELL,
+ MOUSEOUT_CELL,
+ INPUT_CELL,
+ PASTE_CELL,
+ RESIZE_COLUMN,
+ SCROLL,
+ CHANGED_VALUE,
+} = cheetahGrid.ListGrid.EVENT_TYPE;
+
+grid.listen(CLICK_CELL, (...args) => log(CLICK_CELL, args));
+grid.listen(DBLCLICK_CELL, (...args) => log(DBLCLICK_CELL, args));
+grid.listen(DBLTAP_CELL, (...args) => log(DBLTAP_CELL, args));
+grid.listen(MOUSEDOWN_CELL, (...args) => log(MOUSEDOWN_CELL, args));
+grid.listen(MOUSEUP_CELL, (...args) => log(MOUSEUP_CELL, args));
+grid.listen(SELECTED_CELL, (...args) => log(SELECTED_CELL, args));
+grid.listen(KEYDOWN, (...args) => log(KEYDOWN, args));
+grid.listen(INPUT_CELL, (...args) => log(INPUT_CELL, args));
+grid.listen(PASTE_CELL, (...args) => log(PASTE_CELL, args));
+grid.listen(RESIZE_COLUMN, (...args) => log(RESIZE_COLUMN, args));
+grid.listen(SCROLL, (...args) => log(SCROLL, args));
+
+grid.listen(CHANGED_VALUE, (...args) => log(CHANGED_VALUE, args));
+
+grid.listen(MOUSEMOVE_CELL, (...args) => {
+ if (!document.querySelector(".include-mouse").checked) {
+ return;
+ }
+ log(MOUSEMOVE_CELL, args);
+});
+grid.listen(MOUSEENTER_CELL, (...args) => {
+ if (!document.querySelector(".include-mouse").checked) {
+ return;
+ }
+ log(MOUSEENTER_CELL, args);
+});
+grid.listen(MOUSELEAVE_CELL, (...args) => {
+ if (!document.querySelector(".include-mouse").checked) {
+ return;
+ }
+ log(MOUSELEAVE_CELL, args);
+});
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
Event Name | Description |
---|---|
EVENT_TYPE.CLICK_CELL | Fires when the cell was clicked. |
EVENT_TYPE.DBLCLICK_CELL | Fires when the cell was double-clicked. |
EVENT_TYPE.DBLTAP_CELL | Fires when the cell was double-taped. |
EVENT_TYPE.MOUSEDOWN_CELL | Fires when pointing device button is pressed in a cell. |
EVENT_TYPE.MOUSEUP_CELL | Fires when pointing device button is released in a cell. |
EVENT_TYPE.SELECTED_CELL | Fires when the cell selection state has changed. |
EVENT_TYPE.KEYDOWN | Fires key-downed. |
EVENT_TYPE.MOUSEMOVE_CELL | TBA |
EVENT_TYPE.MOUSEENTER_CELL | TBA |
EVENT_TYPE.MOUSELEAVE_CELL | TBA |
EVENT_TYPE.MOUSEOVER_CELL | TBA |
EVENT_TYPE.MOUSEOUT_CELL | TBA |
EVENT_TYPE.CONTEXTMENU_CELL | Fires when the user attempts to open a context menu in the cell. |
EVENT_TYPE.INPUT_CELL | TBA |
EVENT_TYPE.PASTE_CELL | TBA |
EVENT_TYPE.DELETE_CELL | TBA |
EVENT_TYPE.EDITABLEINPUT_CELL | TBA |
EVENT_TYPE.MODIFY_STATUS_EDITABLEINPUT_CELL | TBA |
EVENT_TYPE.RESIZE_COLUMN | Fires when the column width has changed. |
EVENT_TYPE.SCROLL | Fires when scrolled. |
EVENT_TYPE.FOCUS_GRID | Fires when grid focus is activated. |
EVENT_TYPE.BLUR_GRID | Fires when grid focus is inactivated. |
EVENT_TYPE.BEFORE_CHANGE_VALUE | Notifies that before the cell value changes. |
EVENT_TYPE.CHANGED_VALUE | Fires when the cell value was changed. |
EVENT_TYPE.CHANGED_HEADER_VALUE | Fires when the header cell value was changed. |
EVENT_TYPE.REJECTED_PASTE_VALUES | Notifies that the pasted value has been rejected. |
+ ← + + Selection Property + + Theme + + → +
# FilterDataSource
Filtering the data to be displayed using FilterDataSource
.
+Generate a FilterDataSource
instance by passing DataSource
as the constructor argument.
+If you want to generate from array, describe as new cheetahGrid.data.FilterDataSource(cheetahGrid.data.DataSource.ofArray(array))
.
<label>Filter:</label><input class="sample1-filter-input" />
+<div class="sample1 demo-grid large"></div>
+
2
/**
+ * @type {DataSource}
+ */
+const personsDataSource = generatePersonsDataSource(1000000);
+const filterDataSource = new cheetahGrid.data.FilterDataSource(
+ personsDataSource
+);
+
+const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ {
+ field: "check",
+ caption: "",
+ width: 50,
+ columnType: "check",
+ action: "check",
+ },
+ { field: "personid", caption: "ID", width: 100 },
+ {
+ caption: "name",
+ columns: [
+ { field: "fname", caption: "First Name", width: 200 },
+ { field: "lname", caption: "Last Name", width: 200 },
+ ],
+ },
+ { field: "email", caption: "Email", width: 250 },
+ {
+ field(rec) {
+ const d = rec.birthday;
+ return `${d.getFullYear()}/${d.getMonth() + 1}/${d.getDate()}`;
+ },
+ caption: "birthday",
+ width: 100,
+ },
+ {
+ caption: "button",
+ width: 120,
+ /* button column */
+ columnType: new cheetahGrid.columns.type.ButtonColumn({
+ caption: "SHOW REC",
+ }),
+ action: new cheetahGrid.columns.action.ButtonAction({
+ action(rec) {
+ alert(JSON.stringify(rec));
+ },
+ }),
+ },
+ ],
+ frozenColCount: 2,
+});
+grid.dataSource = filterDataSource;
+
+const input = document.querySelector(".sample1-filter-input");
+input.addEventListener("input", () => {
+ const filterValue = input.value;
+ filterDataSource.filter = filterValue
+ ? (record) => {
+ // filtering method
+ for (const k in record) {
+ if (`${record[k]}`.indexOf(filterValue) >= 0) {
+ return true;
+ }
+ }
+ return false;
+ }
+ : null;
+ // Please call `invalidate()`
+ grid.invalidate();
+});
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Using Promise
s
This feature is available even if record data is Promise
.
<label>Filter:</label><input class="sample2-filter-input" />
+<div class="sample2 demo-grid large"></div>
+
2
const personsDataSource = new cheetahGrid.data.CachedDataSource({
+ get(index) {
+ return new Promise((resolve) => {
+ console.log(`get record:${index}`);
+ setTimeout(() => {
+ resolve(generatePerson(index));
+ }, 300);
+ });
+ },
+ length: 1000000,
+});
+
+const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample2"),
+ header: [
+ {
+ field: "check",
+ caption: "",
+ width: 50,
+ columnType: "check",
+ action: "check",
+ },
+ { field: "personid", caption: "ID", width: 100 },
+ {
+ caption: "name",
+ columns: [
+ { field: "fname", caption: "First Name", width: 200 },
+ { field: "lname", caption: "Last Name", width: 200 },
+ ],
+ },
+ { field: "email", caption: "Email", width: 250 },
+ {
+ field(rec) {
+ const d = rec.birthday;
+ return `${d.getFullYear()}/${d.getMonth() + 1}/${d.getDate()}`;
+ },
+ caption: "birthday",
+ width: 100,
+ },
+ {
+ caption: "button",
+ width: 120,
+ /* button column */
+ columnType: new cheetahGrid.columns.type.ButtonColumn({
+ caption: "SHOW REC",
+ }),
+ action: new cheetahGrid.columns.action.ButtonAction({
+ action(rec) {
+ alert(JSON.stringify(rec));
+ },
+ }),
+ },
+ ],
+ frozenColCount: 2,
+});
+const filterDataSource = new cheetahGrid.data.FilterDataSource(
+ personsDataSource
+);
+grid.dataSource = filterDataSource;
+
+const input = document.querySelector(".sample2-filter-input");
+input.addEventListener("input", () => {
+ const filterValue = input.value;
+ filterDataSource.filter = filterValue
+ ? (record) => {
+ // filtering method
+ for (const k in record) {
+ if (`${record[k]}`.indexOf(filterValue) >= 0) {
+ return true;
+ }
+ }
+ return false;
+ }
+ : null;
+ // Please call `invalidate()`
+ grid.invalidate();
+});
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
+ ← + + Using Promises + + Selection Property + + → +
# Grid Data
Can use the Array
object or cheetahGrid.data.DataSource
object for grid data.
# Using Array
object
<div class="sample1 demo-grid middle"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ { field: "personid", caption: "ID", width: 100 },
+ { field: "fname", caption: "First Name", width: 200 },
+ { field: "lname", caption: "Last Name", width: 200 },
+ { field: "email", caption: "Email", width: 250 },
+ ],
+ frozenColCount: 1,
+});
+// set array records
+grid.records = [
+ {
+ personid: 1,
+ fname: "Sophia",
+ lname: "Hill",
+ email: "sophia_hill@example.com",
+ },
+ {
+ personid: 2,
+ fname: "Aubrey",
+ lname: "Martin",
+ email: "aubrey_martin@example.com",
+ },
+ {
+ personid: 3,
+ fname: "Avery",
+ lname: "Jones",
+ email: "avery_jones@example.com",
+ },
+ {
+ personid: 4,
+ fname: "Joseph",
+ lname: "Rodriguez",
+ email: "joseph_rodriguez@example.com",
+ },
+ {
+ personid: 5,
+ fname: "Samuel",
+ lname: "Campbell",
+ email: "samuel_campbell@example.com",
+ },
+ {
+ personid: 6,
+ fname: "Joshua",
+ lname: "Ortiz",
+ email: "joshua_ortiz@example.com",
+ },
+ {
+ personid: 7,
+ fname: "Mia",
+ lname: "Foster",
+ email: "mia_foster@example.com",
+ },
+ {
+ personid: 8,
+ fname: "Landon",
+ lname: "Lopez",
+ email: "landon_lopez@example.com",
+ },
+ {
+ personid: 9,
+ fname: "Audrey",
+ lname: "Cox",
+ email: "audrey_cox@example.com",
+ },
+ {
+ personid: 10,
+ fname: "Anna",
+ lname: "Ramirez",
+ email: "anna_ramirez@example.com",
+ },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Using cheetahGrid.data.DataSource
object
<div class="sample2 demo-grid middle"></div>
+
// define cache
+const array = [];
+const getPerson = (index) =>
+ array[index] || (array[index] = generatePerson(index));
+
+const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample2"),
+ header: [
+ { field: "personid", caption: "ID", width: 100 },
+ { field: "fname", caption: "First Name", width: 200 },
+ { field: "lname", caption: "Last Name", width: 200 },
+ { field: "email", caption: "Email", width: 250 },
+ ],
+ frozenColCount: 1,
+});
+grid.dataSource = new cheetahGrid.data.CachedDataSource({
+ // Get record method
+ get(index) {
+ return getPerson(index);
+ },
+ // Number of records
+ length: 10000,
+});
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
cheetahGrid.data.DataSource
has subclasses
+cheetahGrid.data.CachedDataSource
and cheetahGrid.data.FilterDataSource
CachedDataSource
has the ability to cache the return value if the record is a Promise
object.
+If you know that the record does not become Promise
, you can use DataSource
,
+In this case it is recommended to use CachedDataSource
as CachedDataSource
does not change in behavior.
+ ← + + Define Column Actions + + Using Promises + + → +
# Using Promise
s
Cheetah Grid supports Promise
object.
+We suppose the situations below as a example.
- Get the record informations as deferred
+Get and show a few records in first view. Remaining records are shown when scrolled. - Get the cell informations as deferred
+Get and show the important informations in first view. Remaining details are shown later.
# Promise
Records
Shows usage below.
In this example grid shows 1,000 recors as a whole. Getting 100 records by each ajax is supposed.
<textarea
+ class="rec_sample_log"
+ style="width: 100%; height: 100px;"
+ readonly="true"
+>
+ajax logs</textarea
+>
+<div class="rec_sample demo-grid middle"></div>
+
2
3
4
5
6
7
8
getRecordsWithAjax
in example code returns Promise
object which get 100 records by ajax.
const getRecordsWithAjax = (startIndex, num) =>
+ new Promise((resolve) => {
+ setTimeout(() => {
+ const records = [];
+ for (let i = 0; i < num; i++) {
+ records.push(generatePerson(startIndex + i));
+ }
+ const log = document.querySelector(".rec_sample_log");
+ log.value += `\nAcquire ${num} data from index ${startIndex}.`;
+ log.value = log.value.trim();
+ log.scrollTop = log.scrollHeight;
+
+ resolve(records);
+ }, 500);
+ });
+
+// create DataSource
+const loadedData = {};
+const dataSource = new cheetahGrid.data.CachedDataSource({
+ get(index) {
+ const loadStartIndex = Math.floor(index / 100) * 100;
+ if (!loadedData[loadStartIndex]) {
+ const promiseObject = getRecordsWithAjax(loadStartIndex, 100); // return Promise Object
+ loadedData[loadStartIndex] = promiseObject;
+ }
+ return loadedData[loadStartIndex].then(
+ (data) => data[index - loadStartIndex]
+ );
+ },
+ length: 1000, //all records count
+});
+
+// create cheetahGrid
+const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".rec_sample"),
+ header: [
+ { field: "personid", caption: "ID", width: 100 },
+ { field: "fname", caption: "First Name", width: 200 },
+ { field: "lname", caption: "Last Name", width: 200 },
+ { field: "email", caption: "Email", width: 250 },
+ {
+ field: (rec) => new Intl.DateTimeFormat().format(rec.birthday),
+ caption: "birthday",
+ width: 200,
+ },
+ ],
+ frozenColCount: 1,
+});
+grid.configure("fadeinWhenCallbackInPromise", true);
+
+// set dataSource
+grid.dataSource = dataSource;
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Promise
Cells
Example below shows Person data. Department informations are shown later by ajax.
<textarea
+ class="cell_sample_log"
+ style="width: 100%; height: 100px;"
+ readonly="true"
+>
+ajax logs</textarea
+>
+<div class="cell_sample demo-grid middle"></div>
+
2
3
4
5
6
7
8
getPersonDeptWithAjax
in example code returns Promise
object which get department information by ajax.
const records = generatePersons(1000);
+const depts = [
+ "General Affairs",
+ "Personal",
+ "General Accounting",
+ "Sales",
+ "Sales Promotion",
+ "Procurement",
+ "Development",
+ "Engineering",
+ "Manufacturing",
+ "Procurement",
+ "Export",
+ "Public Relations",
+ "Information & Research",
+ "Legal",
+ "Advertising",
+ "Planning",
+ "Secretary",
+];
+const getPersonDeptWithAjax = (personid) =>
+ new Promise((resolve) => {
+ setTimeout(() => {
+ const dept = depts[Math.floor(Math.random() * depts.length)];
+ const log = document.querySelector(".cell_sample_log");
+ log.value += `\nAcquire department data of personid: ${personid}. => department: ${dept}`;
+ log.value = log.value.trim();
+ log.scrollTop = log.scrollHeight;
+
+ resolve(dept);
+ }, 500);
+ });
+
+const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".cell_sample"),
+ header: [
+ { field: "personid", caption: "ID", width: 100 },
+ { field: "fname", caption: "First Name", width: 200 },
+ { field: "lname", caption: "Last Name", width: 200 },
+ { field: "email", caption: "Email", width: 250 },
+ {
+ field(rec) {
+ return getPersonDeptWithAjax(rec.personid); // return Promise Object
+ },
+ caption: "Department",
+ width: 250,
+ },
+ ],
+ frozenColCount: 1,
+});
+grid.configure("fadeinWhenCallbackInPromise", true);
+
+grid.records = records;
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
+ ← + + Grid Data + + FilterDataSource + + → +
# Define Headers and Columns
# Standard Column
The header
property, the property of cheetahGrid.ListGrid
, decides the behave and appearance of columns and header cells.
+We can set this property by constructor arguments or instance property.
The header
property must be set by objects array (Array<object>
).
+In the standard definition, each object consists of following properties.
Property | Type | Description | LINK |
---|---|---|---|
caption | string | define the header caption | --- |
field | string | function | {get:function,set?:function} | define the field name, getter function, or accessor object of the record to display in the cell | --- |
width | string | number | define the width of column | link |
minWidth | string | number | define the minimum width of column | link |
maxWidth | string | number | define the maximum width of column | link |
columnType | string | object | define the type of column | link |
style | string | object | function | define the style of column | link |
action | string | object | define the action of column | link |
<div class="sample1 demo-grid middle"></div>
+
/*
+ record object properties
+ {
+ personid: 'ID',
+ fname: 'First Name',
+ lname: 'Last Name',
+ email: 'Email',
+ birthday: 'birthday',
+ }
+ */
+const records = generatePersons(100);
+
+const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ { field: "personid", caption: "ID", width: 100 },
+ { field: "fname", caption: "First Name", width: 200 },
+ { field: "lname", caption: "Last Name", width: 200 },
+ { field: "email", caption: "Email", width: 250 },
+ { field: getBirthday, caption: "Birthday", width: 200 },
+ ],
+ frozenColCount: 1,
+});
+grid.records = records;
+
+function getBirthday(rec) {
+ const dateTimeFormat = new Intl.DateTimeFormat("en-US", {
+ year: "numeric",
+ month: "numeric",
+ day: "numeric",
+ });
+ return dateTimeFormat.format(rec.birthday);
+}
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# field
property
field
is one of the most basic properties. It provides the data to display from the record to the cell.
+You can choose and define one of the 3 formats.
# string format
Define the property name to get the cell data from the record as a string.
For example:
const grid = new cheetahGrid.ListGrid({
+ // ...
+ header: [
+ // ...
+ {
+ field: "email",
+ // ...
+ },
+ // ...
+ ],
+ // ...
+});
+
2
3
4
5
6
7
8
9
10
11
12
# function format
Define the getter function that get the cell data from the record.
For example:
const grid = new cheetahGrid.ListGrid({
+ // ...
+ header: [
+ // ...
+ {
+ field: (record) => record.email,
+ // ...
+ },
+ // ...
+ ],
+ // ...
+});
+
2
3
4
5
6
7
8
9
10
11
12
# object format
Define an object with a getter function that gets the cell data from the record and a setter function that sets the cell data to the record.
For example:
const grid = new cheetahGrid.ListGrid({
+ // ...
+ header: [
+ // ...
+ {
+ field: {
+ get: (record) => record.email,
+ set: (record, newValue) => (record.email = newValue),
+ },
+ // ...
+ },
+ // ...
+ ],
+ // ...
+});
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Multiple Header
To use multiple header, set the hierarchical structured Object to the header
property.
<div class="sample2 demo-grid middle"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample2"),
+ header: [
+ { field: "personid", caption: "ID", width: 100 },
+ {
+ /* multiple header */
+ caption: "name",
+ columns: [
+ { field: "fname", caption: "First Name", width: 200 },
+ { field: "lname", caption: "Last Name", width: 200 },
+ ],
+ },
+ { field: "email", caption: "Email", width: 250 },
+ { field: getBirthday, caption: "Birthday", width: 200 },
+ ],
+ frozenColCount: 1,
+});
+grid.records = records;
+
+function getBirthday(rec) {
+ const dateTimeFormat = new Intl.DateTimeFormat("en-US", {
+ year: "numeric",
+ month: "numeric",
+ day: "numeric",
+ });
+ return dateTimeFormat.format(rec.birthday);
+}
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+ ← + + API for JavaScript + + Define Column Width + + → +
# API for JavaScript
+ ← + + API + + Define Headers and Columns + + → +
# Examples of allowRangePaste
- Simple Layout
<div class="sample1 demo-grid large"></div>
+
const menuOptions = [
+ { value: "", label: "Empty" },
+ { value: "1", label: "Option 1" },
+ { value: "2", label: "Option 2" },
+ { value: "3", label: "Option 3" },
+ { value: "4", label: "Option 4" },
+ { value: "5", label: "Option 5" },
+ { value: "6", label: "Option 6" },
+ { value: "7", label: "Option 7" },
+];
+const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ allowRangePaste: true, // Allow pasting of range.
+ header: [
+ {
+ field: "selected",
+ caption: "",
+ width: 80,
+ columnType: "check",
+ action: "check",
+ },
+ { field: "personid", caption: "ID", width: 100, action: "input" },
+ {
+ field: "fname",
+ caption: "First Name",
+ width: "auto",
+ minWidth: 30,
+ action: "input",
+ },
+ {
+ field: "lname",
+ caption: "Last Name",
+ width: "auto",
+ minWidth: 30,
+ action: "input",
+ },
+ {
+ field: "email",
+ caption: "Email",
+ width: "auto",
+ minWidth: 30,
+ action: "input",
+ },
+ {
+ field: "option",
+ caption: "Option",
+ width: "auto",
+ minWidth: 30,
+ columnType: new cheetahGrid.columns.type.MenuColumn({
+ options: menuOptions,
+ }),
+ action: new cheetahGrid.columns.action.InlineMenuEditor({
+ options: menuOptions,
+ }),
+ },
+ ],
+ frozenColCount: 1,
+});
+
+grid.records = [
+ {
+ personid: 1,
+ fname: "Sophia",
+ lname: "Hill",
+ email: "sophia_hill@example.com",
+ option: "",
+ },
+ {
+ personid: 2,
+ fname: "Aubrey",
+ lname: "Martin",
+ email: "aubrey_martin@example.com",
+ option: "",
+ },
+ {
+ personid: 3,
+ fname: "Avery",
+ lname: "Jones",
+ email: "avery_jones@example.com",
+ option: "",
+ },
+ {
+ personid: 4,
+ fname: "Joseph",
+ lname: "Rodriguez",
+ email: "joseph_rodriguez@example.com",
+ option: "",
+ },
+ {
+ personid: 5,
+ fname: "Samuel",
+ lname: "Campbell",
+ email: "samuel_campbell@example.com",
+ option: "",
+ },
+ {
+ personid: 6,
+ fname: "Joshua",
+ lname: "Ortiz",
+ email: "joshua_ortiz@example.com",
+ option: "",
+ },
+ {
+ personid: 7,
+ fname: "Mia",
+ lname: "Foster",
+ email: "mia_foster@example.com",
+ option: "",
+ },
+ {
+ personid: 8,
+ fname: "Landon",
+ lname: "Lopez",
+ email: "landon_lopez@example.com",
+ option: "",
+ },
+ {
+ personid: 9,
+ fname: "Audrey",
+ lname: "Cox",
+ email: "audrey_cox@example.com",
+ option: "",
+ },
+ {
+ personid: 10,
+ fname: "Anna",
+ lname: "Ramirez",
+ email: "anna_ramirez@example.com",
+ option: "",
+ },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
- Advanced Layout
<div class="sample2 demo-grid large"></div>
+
const menuOptions = [
+ { value: "", label: "Empty" },
+ { value: "1", label: "Option 1" },
+ { value: "2", label: "Option 2" },
+ { value: "3", label: "Option 3" },
+ { value: "4", label: "Option 4" },
+ { value: "5", label: "Option 5" },
+ { value: "6", label: "Option 6" },
+ { value: "7", label: "Option 7" },
+];
+const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample2"),
+ allowRangePaste: true, // Allow pasting of range.
+ layout: {
+ header: [
+ [
+ { caption: "", rowSpan: 2, width: 80 },
+ { caption: "ID", rowSpan: 2, width: 100 },
+ { caption: "First Name", width: "auto", minWidth: 30 },
+ { caption: "Email", width: "auto", minWidth: 30 },
+ ],
+ [{ caption: "Last Name" }, { caption: "Option" }],
+ ],
+ body: [
+ [
+ { field: "selected", rowSpan: 2, columnType: "check", action: "check" },
+ { field: "personid", rowSpan: 2, action: "input" },
+ { field: "fname", action: "input" },
+ { field: "email", action: "input" },
+ ],
+ [
+ { field: "lname", action: "input" },
+ {
+ field: "option",
+ columnType: new cheetahGrid.columns.type.MenuColumn({
+ options: menuOptions,
+ }),
+ action: new cheetahGrid.columns.action.InlineMenuEditor({
+ options: menuOptions,
+ }),
+ },
+ ],
+ ],
+ },
+ frozenColCount: 1,
+});
+
+grid.records = [
+ {
+ personid: 1,
+ fname: "Sophia",
+ lname: "Hill",
+ email: "sophia_hill@example.com",
+ option: "",
+ },
+ {
+ personid: 2,
+ fname: "Aubrey",
+ lname: "Martin",
+ email: "aubrey_martin@example.com",
+ option: "",
+ },
+ {
+ personid: 3,
+ fname: "Avery",
+ lname: "Jones",
+ email: "avery_jones@example.com",
+ option: "",
+ },
+ {
+ personid: 4,
+ fname: "Joseph",
+ lname: "Rodriguez",
+ email: "joseph_rodriguez@example.com",
+ option: "",
+ },
+ {
+ personid: 5,
+ fname: "Samuel",
+ lname: "Campbell",
+ email: "samuel_campbell@example.com",
+ option: "",
+ },
+ {
+ personid: 6,
+ fname: "Joshua",
+ lname: "Ortiz",
+ email: "joshua_ortiz@example.com",
+ option: "",
+ },
+ {
+ personid: 7,
+ fname: "Mia",
+ lname: "Foster",
+ email: "mia_foster@example.com",
+ option: "",
+ },
+ {
+ personid: 8,
+ fname: "Landon",
+ lname: "Lopez",
+ email: "landon_lopez@example.com",
+ option: "",
+ },
+ {
+ personid: 9,
+ fname: "Audrey",
+ lname: "Cox",
+ email: "audrey_cox@example.com",
+ option: "",
+ },
+ {
+ personid: 10,
+ fname: "Anna",
+ lname: "Ramirez",
+ email: "anna_ramirez@example.com",
+ option: "",
+ },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Cautionary Notes
Even if you set validator
or inputValidator
using SmallDialogInputEditor, overwrites the pasted value even if the value is invalid.
+Use Cell Message API to notify the user of an invalid value.
<div class="sample3 demo-grid large"></div>
+
const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample3"),
+ allowRangePaste: true, // Allow pasting of range.
+ header: [
+ {
+ field: "number",
+ caption: "Number",
+ width: "auto",
+ action: new cheetahGrid.columns.action.SmallDialogInputEditor({
+ inputValidator(value) {
+ return value && isNaN(value) ? "Not a number." : null;
+ },
+ }),
+ message(record) {
+ const value = record.number;
+ return value && isNaN(value) ? "Not a number." : null;
+ },
+ },
+ { field: "text", caption: "Text", width: "auto" },
+ ],
+});
+
+grid.records = [
+ { number: 1, text: "text" },
+ { number: 2, text: "text" },
+ { number: 3, text: "text" },
+ { number: 4, text: "text" },
+ { number: 5, text: "text" },
+];
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+ ← + + Options and Properties + + keyboardOptions + + → +
# Options and Properties
# cheetahGrid.ListGrid
# Constructor Options
Property | Type | Description |
---|---|---|
header | HeadersDefine | Define simple headers and layout. This property cannot be used with the layout property. See Define Headers and Columns. |
layout | LayoutDefine | Define advanced headers and layout. This property cannot be used with the header property. See Advanced Layout. |
records | Array | Records. This property cannot be used with the dataSource property. See Grid Data. |
dataSource | DataSource | The data source that supplies the records. This property cannot be used with the records property. See Grid Data. |
parentElement | HTMLElement | Specify the parent element. |
frozenColCount | number | Specify the number of columns to be frozen to the left. |
defaultRowHeight | number | Specify the default grid rows height. |
defaultColWidth | number | Specify the default grid columns width. |
headerRowHeight | number[] / number | Specify the header row(s) height. |
theme | ThemeDefine / string | Specify the theme. See Theme. |
font | string | Specify the default font. |
underlayBackgroundColor | string | Specify the underlay background color. |
allowRangePaste | boolean | Specify true to allow pasting of the range. See Examples of allowRangePaste. |
trimOnPaste | boolean | Specify true , trim the pasted text on pasting. |
disableColumnResize | boolean | Specify true to disable column resize. |
keyboardOptions.moveCellOnTab | boolean / function | Specify true to enable cell movement by Tab key. You can also specify a function that determines which cell to move to. |
keyboardOptions.moveCellOnEnter | boolean / function | Specify true to enable cell movement by Enter key. You can also specify a function that determines which cell to move to. |
keyboardOptions.deleteCellValueOnDel | boolean | Specify true to enable enable deletion of cell values with the Del and BS keys. |
keyboardOptions.selectAllOnCtrlA | boolean | Specify true to enable select all cells by Ctrl + A key. |
# Properties
Property | Type | Description |
---|---|---|
header | HeadersDefine | Same as the constructor option. |
layout | LayoutDefine | Same as the constructor option. |
records | Array | Same as the constructor option. |
dataSource | DataSource | Same as the constructor option. |
frozenColCount | number | Same as the constructor option. |
defaultRowHeight | number | Same as the constructor option. |
defaultColWidth | number | Same as the constructor option. |
theme | ThemeDefine / string | Same as the constructor option. |
font | string | Same as the constructor option. |
underlayBackgroundColor | string | Same as the constructor option. |
allowRangePaste | boolean | Same as the constructor option. |
trimOnPaste | boolean | Same as the constructor option. |
keyboardOptions | object | Same as the constructor option. |
sortState | SortState | Sort state. |
headerValues | Map | A map of the values entered in the header. |
+ ← + + Advanced Layout + + Examples of allowRangePaste + + → +
# keyboardOptions
You can set the keyboard operation.
# Focus and Edit
If not set, the user can operate the cell with the keyboard as follows.
Cell | Arrow | Ctrl (or Meta) + Arrow | Home or End | Ctrl (or Meta) + Home or End | Enter | Tab | Space | Backspace | Delete |
---|---|---|---|---|---|---|---|---|---|
Normal (can't Edit) | Move one. | Move to edge. | Move to side edge. | Move to upper left or lower right. | -- | (native) | -- | -- | -- |
Input | Move one. | Move to edge. | Move to side edge. | Move to upper left or lower right. | Enter input mode. | (native) | Enter input mode. And input space. | -- | -- |
Input (Input Mode) | (input native) | (input native) | (input native) | (input native) | Apply input and exit input mode. | (native) | (input native) | (input native) | (input native) |
Inline Input | Move one. | Move to edge. | Move to side edge. | Move to upper left or lower right. | Enter input mode. | (native) | Enter input mode. And input space. | -- | -- |
Inline Input (Input Mode) | (input native) | (input native) | (input native) | (input native) | Apply input and exit input mode. | (native) | (input native) | (input native) | (input native) |
Check | Move one. | Move to edge. | Move to side edge. | Move to upper left or lower right. | Toggle. | (native) | Toggle. | -- | -- |
Dropdown | Move one. | Move to edge. | Move to side edge. | Move to upper left or lower right. | Enter select mode. | (native) | -- | -- | -- |
Dropdown (Select Mode) | Change selection. | (native) | (native) | (native) | Apply selection and exit select mode. | Change selection. | -- | -- | -- |
Button | Move one. | Move to edge. | Move to side edge. | Move to upper left or lower right. | Action. | (native) | Action. | -- | -- |
# moveCellOnTab
Set to true
to enable cell movement by Tab
key.
+If keyboardOptions.moveCellOnTab
is set to true
, the user can operate the cell with the keyboard as follows.
Cell | Arrow | Ctrl (or Meta) + Arrow | Home or End | Ctrl (or Meta) + Home or End | Enter | Tab | Space | Backspace | Delete |
---|---|---|---|---|---|---|---|---|---|
Normal (can't Edit) | Move one. | Move to edge. | Move to side edge. | Move to upper left or lower right. | -- | Move one to next on right. | -- | -- | -- |
Input | Move one. | Move to edge. | Move to side edge. | Move to upper left or lower right. | Enter input mode. | Move one to next on right. | Enter input mode. And input space. | -- | -- |
Input (Input Mode) | (input native) | (input native) | (input native) | (input native) | Apply input and exit input mode. | (native) | (input native) | (input native) | (input native) |
Inline Input | Move one. | Move to edge. | Move to side edge. | Move to upper left or lower right. | Enter input mode. | Move one to next on right. | Enter input mode. And input space. | -- | -- |
Inline Input (Input Mode) | (input native) | (input native) | (input native) | (input native) | Apply input and exit input mode. | Move one to next on right. | (input native) | (input native) | (input native) |
Check | Move one. | Move to edge. | Move to side edge. | Move to upper left or lower right. | Toggle. | Move one to next on right. | Toggle. | -- | -- |
Dropdown | Move one. | Move to edge. | Move to side edge. | Move to upper left or lower right. | Enter select mode. | Move one to next on right. | -- | -- | -- |
Dropdown (Select Mode) | Change selection. | (native) | (native) | (native) | Apply selection and exit select mode. | Move one to next on right. And apply selection. | -- | -- | -- |
Button | Move one. | Move to edge. | Move to side edge. | Move to upper left or lower right. | Action. | Move one to next on right. | Action. | -- | -- |
# moveCellOnEnter
Set to true
to enable cell movement by Enter
key.
+If keyboardOptions.moveCellOnEnter
is set to true
, the user can operate the cell with the keyboard as follows.
Cell | Arrow | Ctrl (or Meta) + Arrow | Home or End | Ctrl (or Meta) + Home or End | Enter | Tab | Space | Backspace | Delete |
---|---|---|---|---|---|---|---|---|---|
Normal (can't Edit) | Move one. | Move to edge. | Move to side edge. | Move to upper left or lower right. | Move one to next on down. | Move one to next on right. | -- | -- | -- |
Input | Move one. | Move to edge. | Move to side edge. | Move to upper left or lower right. | Enter input mode. | Move one to next on right. | Enter input mode. And input space. | -- | -- |
Input (Input Mode) | (input native) | (input native) | (input native) | (input native) | Move one to next on down. And apply input. | (native) | (input native) | (input native) | (input native) |
Inline Input | Move one. | Move to edge. | Move to side edge. | Move to upper left or lower right. | Enter input mode. | Move one to next on right. | Enter input mode. And input space. | -- | -- |
Inline Input (Input Mode) | (input native) | (input native) | (input native) | (input native) | Move one to next on down. And apply input. | Move one to next on right. | (input native) | (input native) | (input native) |
Check | Move one. | Move to edge. | Move to side edge. | Move to upper left or lower right. | Move one to next on down. | Move one to next on right. | Toggle. | -- | -- |
Dropdown | Move one. | Move to edge. | Move to side edge. | Move to upper left or lower right. | Enter select mode. | Move one to next on right. | -- | -- | -- |
Dropdown (Select Mode) | Change selection. | (native) | (native) | (native) | Move one to next on down. And apply selection. | Move one to next on right. And apply selection. | -- | -- | -- |
Button | Move one. | Move to edge. | Move to side edge. | Move to upper left or lower right. | Move one to next on down. | Move one to next on right. | Action. | -- | -- |
# deleteCellValueOnDel
Set to true
to enable enable deletion of cell values with the Del
and BS
keys.
+If keyboardOptions.deleteCellValueOnDel
is set to true
, the user can operate the cell with the keyboard as follows.
Cell | Arrow | Ctrl (or Meta) + Arrow | Home or End | Ctrl (or Meta) + Home or End | Enter | Tab | Space | Backspace | Delete |
---|---|---|---|---|---|---|---|---|---|
Normal (can't Edit) | Move one. | Move to edge. | Move to side edge. | Move to upper left or lower right. | Move one to next on down. | Move one to next on right. | -- | -- | -- |
Input | Move one. | Move to edge. | Move to side edge. | Move to upper left or lower right. | Enter input mode. | Move one to next on right. | Enter input mode. And input space. | Delete value. | Delete value. |
Input (Input Mode) | (input native) | (input native) | (input native) | (input native) | Move one to next on down. And apply input. | (native) | (input native) | (input native) | (input native) |
Inline Input | Move one. | Move to edge. | Move to side edge. | Move to upper left or lower right. | Enter input mode. | Move one to next on right. | Enter input mode. And input space. | Delete value. | Delete value. |
Inline Input (Input Mode) | (input native) | (input native) | (input native) | (input native) | Move one to next on down. And apply input. | Move one to next on right. | (input native) | (input native) | (input native) |
Check | Move one. | Move to edge. | Move to side edge. | Move to upper left or lower right. | Move one to next on down. | Move one to next on right. | Toggle. | -- | -- |
Dropdown | Move one. | Move to edge. | Move to side edge. | Move to upper left or lower right. | Enter select mode. | Move one to next on right. | -- | Delete value, if the cell value can be empty. | Delete value, if the cell value can be empty. |
Dropdown (Select Mode) | Change selection. | (native) | (native) | (native) | Move one to next on down. And apply selection. | Move one to next on right. And apply selection. | -- | -- | -- |
Button | Move one. | Move to edge. | Move to side edge. | Move to upper left or lower right. | Move one to next on down. | Move one to next on right. | Action. | -- | -- |
# selectAllOnCtrlA
Set to true
to enable selectt all cells by Ctrl + A
.
# Selection Property
You can get the area selected by the user from the selection
property.
Property | Description | Exp. |
---|---|---|
selection.select | You can get the selection start position with Object. The row in the Object is the INDEX line containing the header. | {"col": 0, "row": 0} |
selection.range | You can get the selection range with Object. The row in the Object is the INDEX line containing the header. | {"start": {"col": 0, "row": 0}, "end": {"col": 2, "row": 2}} |
<div class="sample1 demo-grid middle"></div>
+<button class="button">SHOW SELECTION</button>
+<pre style="color: #fff" class="result"></pre>
+
2
3
document.querySelector(".button").addEventListener("click", () => {
+ const { select, range } = grid.selection;
+
+ document.querySelector(".result").textContent = `
+select:
+---
+${JSON.stringify(select, null, " ")},
+---
+
+range:
+---
+${JSON.stringify(range, null, " ")},
+---`;
+});
+
+const lang =
+ navigator.language || navigator.userLanguage || navigator.browserLanguage;
+const records = generatePersons(100);
+const grid = new cheetahGrid.ListGrid({
+ parentElement: document.querySelector(".sample1"),
+ header: [
+ { field: "personid", caption: "ID", width: 100 },
+ { field: "fname", caption: "First Name", width: 200 },
+ { field: "lname", caption: "Last Name", width: 200 },
+ { field: "email", caption: "Email", width: 250 },
+ {
+ field(rec) {
+ return rec.birthday.toLocaleString(lang, {
+ year: "numeric",
+ month: "long",
+ day: "numeric",
+ });
+ },
+ caption: "birthday",
+ width: 500,
+ },
+ ],
+ frozenColCount: 1,
+ records,
+});
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
+ ← + + Grid Data + + Events + + → +
# Theme
Can set theme to Cheetah Grid.
+Can settings for grid instance or global.
# Grid instance
Set a theme to the theme
property of the grid instance.
+Built-in themes are MATERIAL_DESIGN
and BASIC
.
<label>theme</label>
+<select class="theme-select1">
+ <option value="" selected="true">unset</option>
+ <option value="MATERIAL_DESIGN">MATERIAL_DESIGN</option>
+ <option value="BASIC">BASIC</option>
+</select>
+<div class="sample1 demo-grid small"></div>
+
2
3
4
5
6
7
const grid = vm.createGrid(document.querySelector(".sample1"));
+
+const themeSelect = document.querySelector(".theme-select1");
+themeSelect.onchange = function () {
+ grid.theme = cheetahGrid.themes.choices[themeSelect.value];
+
+ /* The `theme` property of the grid instance can also be set as a string. */
+ // grid.theme = themeSelect.value;
+};
+themeSelect.onchange();
+
2
3
4
5
6
7
8
9
10
# Global
Set a theme to the cheetahGrid.themes.default
property.
+(default MATERIAL_DESIGN.)
<label>theme</label>
+<select class="theme-select2">
+ <option value="MATERIAL_DESIGN" selected="true">MATERIAL_DESIGN</option>
+ <option value="BASIC">BASIC</option>
+</select>
+<div class="sample2 demo-grid small"></div>
+
2
3
4
5
6
vm.createGrid(document.querySelector(".sample2"));
+
+const themeSelect = document.querySelector(".theme-select2");
+themeSelect.onchange = function () {
+ cheetahGrid.themes.default = cheetahGrid.themes.choices[themeSelect.value];
+
+ // redraw all the grids
+ vm.girdInstances.forEach((grid) => grid.invalidate());
+};
+
+themeSelect.onchange();
+
2
3
4
5
6
7
8
9
10
11
# Extend theme
To extend the theme, do as follows.
<div class="sample3 demo-grid small"></div>
+
const grid = vm.createGrid(document.querySelector(".sample3"));
+
+const userTheme = {
+ color: "red",
+ frozenRowsColor: "red",
+ defaultBgColor: "#FDD",
+ frozenRowsBgColor: "#EAA",
+ selectionBgColor: "#FDA",
+ highlightBgColor: "#FDC",
+ underlayBackgroundColor: "#FEE",
+ // You can also change the theme apply in the state by using callback.
+ frozenRowsBorderColor(args) {
+ const {
+ row,
+ grid: { frozenRowCount },
+ } = args;
+ if (frozenRowCount - 1 === row) {
+ return ["#F88" /*top*/, "#F88" /*right and left*/, "red" /*bottom*/];
+ } else {
+ return "#F88";
+ }
+ },
+ borderColor(args) {
+ const {
+ col,
+ grid: { colCount },
+ } = args;
+ if (colCount - 1 === col) {
+ return ["red" /*top*/, "#F88" /*right*/, "red" /*bottom*/, null /*left*/];
+ } else {
+ return ["red" /*top and bottom*/, null /*right and left*/];
+ }
+ },
+ highlightBorderColor: "#FD5",
+ checkbox: {
+ uncheckBgColor: "#FDD",
+ checkBgColor: "rgb(255, 73, 72)",
+ borderColor: "red",
+ },
+ button: {
+ color: "#FDD",
+ bgColor: "#F55",
+ },
+ font: "16px sans-serif",
+ header: {
+ sortArrowColor: "#D00",
+ },
+ messages: {
+ infoBgColor: "gray",
+ errorBgColor: "red",
+ warnBgColor: "yellow",
+ boxWidth: 12,
+ markHeight: 15,
+ },
+ indicators: {
+ topLeftColor: "blue",
+ topLeftSize: 10,
+ topRightColor: "blue",
+ topRightSize: 10,
+ bottomLeftColor: "blue",
+ bottomLeftSize: 10,
+ bottomRightColor: "blue",
+ bottomRightSize: 10,
+ },
+};
+grid.theme = userTheme;
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
+ ← + + Events + + Define Column ICON + + → +
# Advanced Layout
You can use the layout-header
slot and the layout-body
slot to define advanced header and record layouts.
For example:
<div class="demo-grid middle">
+ <c-grid
+ :data="records"
+ :frozen-col-count="1">
+ <template slot="layout-header">
+ <!-- header line1 -->
+ <c-grid-layout-row>
+ <c-grid-header width="85" rowspan="2">ID</c-grid-header>
+ <c-grid-header
+ width="20%"
+ min-width="150"
+ >
+ First Name
+ </c-grid-header>
+ <c-grid-header width="200" rowspan="2">Birthday</c-grid-header>
+ </c-grid-layout-row>
+ <!-- header line2 -->
+ <c-grid-layout-row>
+ <c-grid-header
+ width= "20%"
+ min-width="150"
+ >
+ Last Name
+ </c-grid-header>
+ </c-grid-layout-row>
+ </template>
+ <template slot="layout-body">
+ <!-- line1 -->
+ <c-grid-layout-row>
+ <c-grid-column field="personid" width="85" rowspan="2"/>
+ <c-grid-input-column
+ field="fname"
+ />
+ <c-grid-column :field="getBirthday" rowspan="2"/>
+ </c-grid-layout-row>
+ <!-- line2 -->
+ <c-grid-layout-row>
+ <c-grid-input-column
+ field="lname"
+ />
+ </c-grid-layout-row>
+ </template>
+ </c-grid>
+</div>
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
+ record object properties
+ {
+ personid: 'ID',
+ fname: 'First Name',
+ lname: 'Last Name',
+ email: 'Email',
+ birthday: 'birthday',
+ }
+ */
+const records = generatePersons(100);
+
+export default {
+ data() {
+ return {
+ records,
+ };
+ },
+ methods: {
+ getBirthday(rec) {
+ const dateTimeFormat = new Intl.DateTimeFormat("en-US", {
+ year: "numeric",
+ month: "numeric",
+ day: "numeric",
+ });
+ return dateTimeFormat.format(rec.birthday);
+ },
+ },
+};
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# CGrid
Defines the Grid.
# Vue Template Structure
<div class="demo-grid middle">
+ <c-grid
+ :data="records"
+ :frozen-col-count="1">
+ <!-- define checkbox -->
+ <c-grid-check-column
+ field="check"
+ width="50" />
+ <c-grid-column
+ field="personid"
+ width= "85"
+ >
+ ID
+ </c-grid-column>
+ <!-- multiple header -->
+ <c-grid-column-group
+ caption="Name">
+ <c-grid-input-column
+ field="fname"
+ width="20%"
+ min-width="150"
+ >
+ First Name
+ </c-grid-input-column>
+ <c-grid-input-column
+ field="lname"
+ width= "20%"
+ min-width="150"
+ >
+ Last Name
+ </c-grid-input-column>
+ </c-grid-column-group>
+ <!-- button -->
+ <c-grid-button-column
+ caption="SHOW REC"
+ width="120"
+ @click="onClickRecord"
+ />
+ </c-grid>
+</div>
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
export default {
+ data() {
+ return {
+ records,
+ };
+ },
+ methods: {
+ onClickRecord(rec) {
+ alert(JSON.stringify(rec));
+ },
+ },
+};
+
2
3
4
5
6
7
8
9
10
11
12
# Slots
# default
slot
Use this slot to set the simple header definition.
+The definition is set to header
property described in Define Headers and Columns
# layout-header
slot
Use this slot to set the layout header definition.
+Use this slot in combination with the layout-body
slot.
+The definition is set to layout.header
property described in Advanced Layout.
# layout-body
slot
Use this slot to set the layout body definition.
+Use this slot in combination with the layout-header
slot.
+The definition is set to layout.body
property described in Advanced Layout.
# Properties
# Optional Properties
Name | Type | Description | Default |
---|---|---|---|
data | Array |object | Defines a records or data source. | undefined |
frozen-col-count | number |string | Defines a frozen col Count | 0 |
header-row-height | number |Array | Defines the header row height(s) | undefined |
allow-range-paste | boolean | Allow pasting of range. | undefined |
trim-on-paste | boolean | Trim the pasted text on pasting. | undefined |
default-row-height | number | Default grid row height. | undefined |
default-col-width | number | Default grid col width. | undefined |
filter | function | Defines a records filter | undefined |
font | string | Default font. | undefined |
underlay-background-color | string | Underlay background color. | undefined |
theme | object |string | Defines the grid theme | undefined |
move-cell-on-tab-key | boolean |function | Specify true to enable cell movement by Tab key. You can also specify a function that determines which cell to move to. | false |
move-cell-on-enter-key | boolean |function | Specify true to enable cell movement by Enter key. You can also specify a function that determines which cell to move to. | false |
delete-cell-value-on-del-key | boolean | Specify true to enable enable deletion of cell values with the Del and BS keys. | undefined |
select-all-on-ctrl-a-key | boolean | Specify true to enable select all cells by Ctrl + A key. | undefined |
disable-column-resize | boolean | Specify true to disable column resizing | undefined |
disabled | boolean | Defines disabled | undefined |
readonly | boolean | Defines readonly | undefined |
options | object | Defines a raw options for Cheetah Grid | undefined |
# Examples of using Properties
# theme
<div class="demo-grid middle">
+ <c-grid
+ :data="records"
+ :theme="userTheme"> <!-- set theme -->
+ <c-grid-check-column field="check" :width="50"/>
+ <c-grid-column field="personid" width= "85">ID</c-grid-column>
+ <c-grid-column-group caption="Name">
+ <c-grid-input-column field="fname" width="20%" min-width="150" :sort="true">First Name</c-grid-input-column>
+ <c-grid-input-column field="lname" width="20%" min-width="150" :sort="true">Last Name</c-grid-input-column>
+ </c-grid-column-group>
+ <c-grid-button-column caption="SHOW REC" width="120" @click="onClickRecord" />
+ </c-grid>
+</div>
+
2
3
4
5
6
7
8
9
10
11
12
13
export default {
+ name: "App",
+ data() {
+ return {
+ records,
+ // you can set the theme name or object.
+ // userTheme: 'BASIC',
+ userTheme: {
+ color: "#2c3e50",
+ frozenRowsColor: "#2c3e50",
+ frozenRowsBgColor: "#40b883",
+ borderColor: "#35495e",
+ frozenRowsBorderColor: "#35495e",
+ checkbox: {
+ checkBgColor: "#35495e",
+ borderColor: "#35495e",
+ },
+ button: {
+ color: "#FFF",
+ bgColor: "#2c3e50",
+ },
+ },
+ };
+ },
+ methods: {
+ onClickRecord(rec) {
+ alert(JSON.stringify(rec));
+ },
+ },
+};
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Data
Name | Type | Initial Value | Description |
---|---|---|---|
headerValues | Map<any, any> | new Map() | Header values. |
# Events
Name | Description |
---|---|
click-cell | Click on cell. |
dblclick-cell | Doubleclick on cell. |
selected-cell | Selected cell. |
paste-cell | Paste on cell. |
changed-value | Changed value. |
changed-header-value | Changed header value. |
and more...
TIP
The events for which the column can be identified emit the same event to each column definition component.
+e.g. <c-grid-column>
<div class="demo-grid middle">
+ <c-grid
+ :data="records"
+ :frozen-col-count="1">
+ <c-grid-column field="personid" width= "85"
+ @click-cell="onClickCell($event, 'ID')"
+ >
+ ID
+ </c-grid-column>
+ <c-grid-input-column field="fname" width="20%"
+ @click-cell="onClickCell($event, 'First Name')"
+ >
+ First Name
+ </c-grid-input-column>
+ <c-grid-input-column field="lname" width= "20%"
+ @click-cell="onClickCell($event, 'Last Name')"
+ >
+ Last Name
+ </c-grid-input-column>
+ </c-grid>
+</div>
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
export default {
+ data() {
+ return {
+ records,
+ };
+ },
+ methods: {
+ onClickCell(event, colName) {
+ alert("Click at " + colName + ": $event=" + JSON.stringify(event));
+ },
+ },
+};
+
2
3
4
5
6
7
8
9
10
11
12
# Methods
Name | Return Type | Description |
---|---|---|
invalidate | --- | Redraws the whole grid. |
updateSize | --- | Apply the changed size. |
updateScroll | --- | Apply the changed scroll size. |
# CGridBranchGraphColumn
Defines branch graph column.
# Vue Template Structure
<div class="demo-grid large">
+ <c-grid
+ :data="records">
+ <c-grid-branch-graph-column
+ :width="200"
+ cache
+ field="command">
+ Graph
+ </c-grid-branch-graph-column>
+ </c-grid>
+</div>
+
2
3
4
5
6
7
8
9
10
11
const records = [
+ {
+ command: [
+ { command: "commit", branch: "main" },
+ { command: "tag", branch: "main", tag: "v1.1.0" },
+ ],
+ },
+ {
+ command: [{ command: "commit", branch: "develop2" }],
+ },
+ {
+ command: [{ command: "merge", branch: { from: "main", to: "develop2" } }],
+ },
+ {
+ command: [{ command: "merge", branch: { from: "develop3", to: "main" } }],
+ },
+ {
+ command: [{ command: "commit", branch: "develop2" }],
+ },
+ {
+ command: [
+ { command: "branch", branch: { from: "main", to: "develop3" } },
+ { command: "commit", branch: "develop3" },
+ ],
+ },
+ {
+ command: [{ command: "branch", branch: { from: "main", to: "develop2" } }],
+ },
+ {
+ command: [{ command: "merge", branch: { from: "develop", to: "main" } }],
+ },
+ {
+ command: [{ command: "commit", branch: "develop" }],
+ },
+ {
+ command: [
+ { command: "commit", branch: "main" },
+ { command: "tag", branch: "main", tag: "v1.0.0" },
+ { command: "branch", branch: { from: "main", to: "develop" } },
+ ],
+ },
+ {
+ command: [
+ { command: "branch", branch: "main" },
+ { command: "commit", branch: "main" },
+ ],
+ },
+];
+export default {
+ data() {
+ return {
+ records,
+ };
+ },
+};
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Slots
# default
slot
Use this slot to set the header caption
# Properties
# Optional Properties
Name | Type | Description | Default |
---|---|---|---|
field | object |string |function | Defines a column data field | undefined |
width | number |string | Defines a default column width | undefined |
min-width | number |string | Defines a column min width | undefined |
max-width | number |string | Defines a column max width | undefined |
column-style | object |string |function | Defines a column style. Same as the style property of the JS API. | undefined |
action | object |string |function | Defines an action | undefined |
caption | string |function | Defines a header caption | '' |
cache | boolean | Enable cache | undefined |
colspan | number |string | Defines the layout colspan. This property can be used when defining in the layout-header and layout-body slots. | undefined |
filter | string |function | Defines a vue filter name | undefined |
header-action | object |string |function | Defines a column header action. Same as the headerAction property of the JS API. | undefined |
header-field | string | Defines a column header data field | undefined |
header-icon | object |string | Defines a header icon | undefined |
header-style | object |string |function | Defines a column header style. Same as the headerStyle property of the JS API | undefined |
header-type | object |string |function | Defines a column header type. Same as the headerStyle property of the JS API | undefined |
icon | object |string |function | Defines an icon. Same as the icon property of the JS API. | undefined |
message | object |string |function | Defines a message generation method. Same as the message property of the JS API. | undefined |
rowspan | number |string | Defines the layout rowspan. This property can be used when defining in the layout-header and layout-body slots. | undefined |
sort | boolean |string |function | Defines a sort. See "Sort by Column" for detail. | undefined |
start | string | Defines a start type | undefined |
# Methods
Name | Return Type | Description |
---|---|---|
invalidate | --- | Redraws the whole grid. |
+ ← + + CGrid + + CGridButtonColumn + + → +
# CGridButtonColumn
Defines button column.
# Vue Template Structure
<div class="demo-grid small">
+ <c-grid
+ :data="records"
+ :frozen-col-count="1">
+ <c-grid-button-column
+ caption="FIXED LABEL"
+ width="120"
+ @click="onClickRecord"
+ >
+ Button1
+ </c-grid-button-column>
+ <c-grid-button-column
+ field="buttonCaption"
+ width="120"
+ @click="onClickRecord"
+ >
+ Button2
+ </c-grid-button-column>
+ </c-grid>
+</div>
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
export default {
+ data() {
+ return {
+ records: [
+ { buttonCaption: "BUTTON1" },
+ { buttonCaption: "BUTTON2" },
+ { buttonCaption: "BUTTON3" },
+ { buttonCaption: "BUTTON4" },
+ { buttonCaption: "BUTTON5" },
+ ],
+ };
+ },
+ methods: {
+ onClickRecord(rec) {
+ alert(JSON.stringify(rec));
+ },
+ },
+};
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Slots
# default
slot
Use this slot to set the header caption
# Properties
# Optional Properties
Name | Type | Description | Default |
---|---|---|---|
field | object |string |function | Defines a column data field | undefined |
width | number |string | Defines a default column width | undefined |
min-width | number |string | Defines a column min width | undefined |
max-width | number |string | Defines a column max width | undefined |
column-style | object |string |function | Defines a column style. Same as the style property of the JS API. | undefined |
caption | string | Defines a button caption | '' |
disabled | boolean |function | Defines disabled. You can also control each record by specifying a function. | false |
colspan | number |string | Defines the layout colspan. This property can be used when defining in the layout-header and layout-body slots. | undefined |
filter | string |function | Defines a vue filter name | undefined |
header-action | object |string |function | Defines a column header action. Same as the headerAction property of the JS API. | undefined |
header-field | string | Defines a column header data field | undefined |
header-icon | object |string | Defines a header icon | undefined |
header-style | object |string |function | Defines a column header style. Same as the headerStyle property of the JS API | undefined |
header-type | object |string |function | Defines a column header type. Same as the headerStyle property of the JS API | undefined |
icon | object |string |function | Defines an icon. Same as the icon property of the JS API. | undefined |
message | object |string |function | Defines a message generation method. Same as the message property of the JS API. | undefined |
rowspan | number |string | Defines the layout rowspan. This property can be used when defining in the layout-header and layout-body slots. | undefined |
sort | boolean |string |function | Defines a sort. See "Sort by Column" for detail. | undefined |
# Events
Name | Description |
---|---|
click | Fired when a click on cell. |
# Methods
Name | Return Type | Description |
---|---|---|
invalidate | --- | Redraws the whole grid. |
+ ← + + CGridBranchGraphColumn + + CGridCheckColumn + + → +
# CGridCheckColumn
Defines checkbox column.
# Vue Template Structure
<div class="demo-grid small">
+ <c-grid
+ :data="records"
+ :frozen-col-count="1">
+ <c-grid-check-column
+ field="c1"
+ width="100"
+ >
+ Check1
+ </c-grid-check-column>
+ <c-grid-check-column
+ field="c2"
+ width="100"
+ >
+ Check2
+ </c-grid-check-column>
+ </c-grid>
+</div>
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
export default {
+ data() {
+ return {
+ records: [
+ { c1: true, c2: false },
+ { c1: false, c2: true },
+ { c1: true, c2: false },
+ { c1: false, c2: true },
+ { c1: true, c2: false },
+ { c1: false, c2: true },
+ { c1: true, c2: false },
+ { c1: false, c2: true },
+ { c1: true, c2: false },
+ { c1: false, c2: true },
+ ],
+ };
+ },
+};
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Slots
# default
slot
Use this slot to set the header caption
# Properties
# Optional Properties
Name | Type | Description | Default |
---|---|---|---|
field | object |string |function | Defines a column data field | undefined |
width | number |string | Defines a default column width | undefined |
min-width | number |string | Defines a column min width | undefined |
max-width | number |string | Defines a column max width | undefined |
column-style | object |string |function | Defines a column style. Same as the style property of the JS API. | undefined |
caption | string |function | Defines a header caption | '' |
disabled | boolean |function | Defines disabled. You can also control each record by specifying a function. | false |
readonly | boolean |function | Defines readonly. You can also control each record by specifying a function. | false |
colspan | number |string | Defines the layout colspan. This property can be used when defining in the layout-header and layout-body slots. | undefined |
filter | string |function | Defines a vue filter name | undefined |
header-action | object |string |function | Defines a column header action. Same as the headerAction property of the JS API. | undefined |
header-field | string | Defines a column header data field | undefined |
header-icon | object |string | Defines a header icon | undefined |
header-style | object |string |function | Defines a column header style. Same as the headerStyle property of the JS API | undefined |
header-type | object |string |function | Defines a column header type. Same as the headerStyle property of the JS API | undefined |
icon | object |string |function | Defines an icon. Same as the icon property of the JS API. | undefined |
message | object |string |function | Defines a message generation method. Same as the message property of the JS API. | undefined |
rowspan | number |string | Defines the layout rowspan. This property can be used when defining in the layout-header and layout-body slots. | undefined |
sort | boolean |string |function | Defines a sort. See "Sort by Column" for detail. | undefined |
# Methods
Name | Return Type | Description |
---|---|---|
invalidate | --- | Redraws the whole grid. |
+ ← + + CGridButtonColumn + + CGridColumn + + → +
# CGridColumn
Defines column.
# Vue Template Structure
<div class="demo-grid middle">
+ <c-grid
+ :data="records"
+ :frozen-col-count="1">
+ <c-grid-column
+ field="check"
+ column-type="check"
+ width="50" />
+ <c-grid-column
+ field="personid"
+ width= "85"
+ >
+ ID
+ </c-grid-column>
+ <c-grid-column
+ field="fname"
+ width="20%"
+ min-width="150"
+ >
+ First Name
+ </c-grid-column>
+ <c-grid-column
+ field="lname"
+ width= "20%"
+ min-width="150"
+ >
+ Last Name
+ </c-grid-column>
+ </c-grid>
+</div>
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
export default {
+ data() {
+ return {
+ records,
+ };
+ },
+};
+
2
3
4
5
6
7
# Slots
# default
slot
Use this slot to set the header caption
# Properties
# Optional Properties
Name | Type | Description | Default |
---|---|---|---|
field | object |string |function | Defines a column data field | undefined |
width | number |string | Defines a default column width | undefined |
min-width | number |string | Defines a column min width | undefined |
max-width | number |string | Defines a column max width | undefined |
column-type | object |string |function | Defines a column type | undefined |
column-style | object |string |function | Defines a column style. Same as the style property of the JS API. | undefined |
action | object |string |function | Defines an action | undefined |
caption | string |function | Defines a header caption | '' |
colspan | number |string | Defines the layout colspan. This property can be used when defining in the layout-header and layout-body slots. | undefined |
filter | string |function | Defines a vue filter name | undefined |
header-action | object |string |function | Defines a column header action. Same as the headerAction property of the JS API. | undefined |
header-field | string | Defines a column header data field | undefined |
header-icon | object |string | Defines a header icon | undefined |
header-style | object |string |function | Defines a column header style. Same as the headerStyle property of the JS API | undefined |
header-type | object |string |function | Defines a column header type. Same as the headerStyle property of the JS API | undefined |
icon | object |string |function | Defines an icon. Same as the icon property of the JS API. | undefined |
message | object |string |function | Defines a message generation method. Same as the message property of the JS API. | undefined |
rowspan | number |string | Defines the layout rowspan. This property can be used when defining in the layout-header and layout-body slots. | undefined |
sort | boolean |string |function | Defines a sort. See "Sort by Column" for detail. | undefined |
# Methods
Name | Return Type | Description |
---|---|---|
invalidate | --- | Redraws the whole grid. |
+ ← + + CGridCheckColumn + + CGridColumnGroup + + → +
# CGridColumnGroup
Defines multiple header.
+Can be used in the default
slot of CGrid
.
# Vue Template Structure
<div class="demo-grid middle">
+ <c-grid
+ :data="records"
+ :frozen-col-count="1">
+ <c-grid-column field="personid" width= "85">ID</c-grid-column>
+ <!-- multiple header -->
+ <c-grid-column-group
+ caption="Name">
+ <c-grid-input-column
+ field="fname"
+ width="20%"
+ min-width="150"
+ >
+ First Name
+ </c-grid-input-column>
+ <c-grid-input-column
+ field="lname"
+ width= "20%"
+ min-width="150"
+ >
+ Last Name
+ </c-grid-input-column>
+ </c-grid-column-group>
+ </c-grid>
+</div>
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
export default {
+ data() {
+ return {
+ records,
+ };
+ },
+};
+
2
3
4
5
6
7
# Slots
# default
slot
Use this slot to set the children columns definition
# Properties
# Optional Properties
Name | Type | Description | Default |
---|---|---|---|
caption | string |function | Defines a header caption | '' |
header-action | object |string |function | Defines a column header action. Same as the headerAction property of the JS API. | undefined |
header-field | string | Defines a column header data field | undefined |
header-icon | object |string | Defines a header icon | undefined |
header-style | object |string |function | Defines a column header style. Same as the headerStyle property of the JS API | undefined |
header-type | object |string |function | Defines a column header type. Same as the headerStyle property of the JS API | undefined |
sort | boolean |string |function | Defines a sort. See "Sort by Column" for detail. | undefined |
# Methods
Name | Return Type | Description |
---|---|---|
invalidate | --- | Redraws the whole grid. |
+ ← + + CGridColumn + + CGridHeader + + → +
# CGridHeader
Defines layout header.
+Can be used in the layout-header
slot of CGrid
.
# Vue Template Structure
<div class="demo-grid middle">
+ <c-grid
+ :data="records"
+ :frozen-col-count="1">
+ <template slot="layout-header">
+ <!-- header line1 -->
+ <c-grid-layout-row>
+ <c-grid-header width="85" rowspan="2">ID</c-grid-header>
+ <c-grid-header
+ width="20%"
+ min-width="150"
+ >
+ First Name
+ </c-grid-header>
+ </c-grid-layout-row>
+ <!-- header line2 -->
+ <c-grid-layout-row>
+ <c-grid-header
+ width= "20%"
+ min-width="150"
+ >
+ Last Name
+ </c-grid-header>
+ </c-grid-layout-row>
+ </template>
+ <template slot="layout-body">
+ <!-- line1 -->
+ <c-grid-layout-row>
+ <c-grid-column field="personid" width="85" rowspan="2"/>
+ <c-grid-input-column
+ field="fname"
+ />
+ </c-grid-layout-row>
+ <!-- line2 -->
+ <c-grid-layout-row>
+ <c-grid-input-column
+ field="lname"
+ />
+ </c-grid-layout-row>
+ </template>
+ </c-grid>
+</div>
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
export default {
+ data() {
+ return {
+ records,
+ };
+ },
+};
+
2
3
4
5
6
7
# Slots
# default
slot
Use this slot to set the header caption
# Properties
# Optional Properties
Name | Type | Description | Default |
---|---|---|---|
width | number |string | Defines a default column width | undefined |
min-width | number |string | Defines a column min width | undefined |
max-width | number |string | Defines a column max width | undefined |
caption | string |function | Defines a header caption | '' |
colspan | number |string | Defines the layout colspan. This property can be used when defining in the layout-header and layout-body slots. | undefined |
header-action | object |string |function | Defines a column header action. Same as the headerAction property of the JS API. | undefined |
header-field | string | Defines a column header data field | undefined |
header-icon | object |string | Defines a header icon | undefined |
header-style | object |string |function | Defines a column header style. Same as the headerStyle property of the JS API | undefined |
header-type | object |string |function | Defines a column header type. Same as the headerStyle property of the JS API | undefined |
rowspan | number |string | Defines the layout rowspan. This property can be used when defining in the layout-header and layout-body slots. | undefined |
sort | boolean |string |function | Defines a sort. See "Sort by Column" for detail. | undefined |
# Methods
Name | Return Type | Description |
---|---|---|
invalidate | --- | Redraws the whole grid. |
+ ← + + CGridColumnGroup + + CGridIconColumn + + → +
# CGridIconColumn
Defines icon column.
# Slots
# default
slot
Use this slot to set the header caption
# Properties
# Optional Properties
Name | Type | Description | Default |
---|---|---|---|
field | object |string |function | Defines a column data field | undefined |
width | number |string | Defines a default column width | undefined |
min-width | number |string | Defines a column min width | undefined |
max-width | number |string | Defines a column max width | undefined |
column-style | object |string |function | Defines a column style. Same as the style property of the JS API. | undefined |
action | object |string |function | Defines an action | undefined |
caption | string |function | Defines a header caption | '' |
colspan | number |string | Defines the layout colspan. This property can be used when defining in the layout-header and layout-body slots. | undefined |
filter | string |function | Defines a vue filter name | undefined |
header-action | object |string |function | Defines a column header action. Same as the headerAction property of the JS API. | undefined |
header-field | string | Defines a column header data field | undefined |
header-icon | object |string | Defines a header icon | undefined |
header-style | object |string |function | Defines a column header style. Same as the headerStyle property of the JS API | undefined |
header-type | object |string |function | Defines a column header type. Same as the headerStyle property of the JS API | undefined |
icon | object |string |function | Defines an icon. Same as the icon property of the JS API. | undefined |
icon-class-name | string |function | Defines an icon class name | undefined |
icon-content | string |function | Defines an icon content | undefined |
icon-name | string |function | Defines an icon name | undefined |
icon-tag-name | string |function | Defines an icon tag name | undefined |
icon-width | number |string |function | Defines an icon width | undefined |
message | object |string |function | Defines a message generation method. Same as the message property of the JS API. | undefined |
rowspan | number |string | Defines the layout rowspan. This property can be used when defining in the layout-header and layout-body slots. | undefined |
sort | boolean |string |function | Defines a sort. See "Sort by Column" for detail. | undefined |
# Methods
Name | Return Type | Description |
---|---|---|
invalidate | --- | Redraws the whole grid. |
+ ← + + CGridHeader + + CGridInputColumn + + → +
# CGridInputColumn
Defines input column.
# Slots
# default
slot
Use this slot to set the header caption
# Properties
# Optional Properties
Name | Type | Description | Default |
---|---|---|---|
field | object |string |function | Defines a column data field | undefined |
width | number |string | Defines a default column width | undefined |
min-width | number |string | Defines a column min width | undefined |
max-width | number |string | Defines a column max width | undefined |
column-type | object |string |function | Defines a column type | undefined |
column-style | object |string |function | Defines a column style. Same as the style property of the JS API. | undefined |
caption | string |function | Defines a header caption | '' |
disabled | boolean |function | Defines disabled. You can also control each record by specifying a function. | false |
readonly | boolean |function | Defines readonly. You can also control each record by specifying a function. | false |
colspan | number |string | Defines the layout colspan. This property can be used when defining in the layout-header and layout-body slots. | undefined |
filter | string |function | Defines a vue filter name | undefined |
header-action | object |string |function | Defines a column header action. Same as the headerAction property of the JS API. | undefined |
header-field | string | Defines a column header data field | undefined |
header-icon | object |string | Defines a header icon | undefined |
header-style | object |string |function | Defines a column header style. Same as the headerStyle property of the JS API | undefined |
header-type | object |string |function | Defines a column header type. Same as the headerStyle property of the JS API | undefined |
helper-text | string |function | Defines a helper text ganarator | undefined |
icon | object |string |function | Defines an icon. Same as the icon property of the JS API. | undefined |
input-class-list | Array |string |function | Defines an input class name | undefined |
input-type | string |function | Defines an input type | undefined |
input-validator | function | Defines an input validator | undefined |
message | object |string |function | Defines a message generation method. Same as the message property of the JS API. | undefined |
rowspan | number |string | Defines the layout rowspan. This property can be used when defining in the layout-header and layout-body slots. | undefined |
sort | boolean |string |function | Defines a sort. See "Sort by Column" for detail. | undefined |
validator | function | Defines a validator | undefined |
# Methods
Name | Return Type | Description |
---|---|---|
invalidate | --- | Redraws the whole grid. |
+ ← + + CGridIconColumn + + CGridLayoutRow + + → +
# CGridLayoutRow
Defines layout row.
+Can be used in the layout-header
slot and the layout-body
slot of CGrid
.
# Vue Template Structure
<div class="demo-grid middle">
+ <c-grid
+ :data="records"
+ :frozen-col-count="1">
+ <template slot="layout-header">
+ <!-- header line1 -->
+ <c-grid-layout-row>
+ <c-grid-header width="85" rowspan="2">ID</c-grid-header>
+ <c-grid-header
+ width="20%"
+ min-width="150"
+ >
+ First Name
+ </c-grid-header>
+ </c-grid-layout-row>
+ <!-- header line2 -->
+ <c-grid-layout-row>
+ <c-grid-header
+ width= "20%"
+ min-width="150"
+ >
+ Last Name
+ </c-grid-header>
+ </c-grid-layout-row>
+ </template>
+ <template slot="layout-body">
+ <!-- line1 -->
+ <c-grid-layout-row>
+ <c-grid-column field="personid" width="85" rowspan="2"/>
+ <c-grid-input-column
+ field="fname"
+ />
+ </c-grid-layout-row>
+ <!-- line2 -->
+ <c-grid-layout-row>
+ <c-grid-input-column
+ field="lname"
+ />
+ </c-grid-layout-row>
+ </template>
+ </c-grid>
+</div>
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
export default {
+ data() {
+ return {
+ records,
+ };
+ },
+};
+
2
3
4
5
6
7
# Slots
# default
slot
Use this slot to set the row layout definition
+ ← + + CGridInputColumn + + CGridLinkColumn + + → +
# CGridLinkColumn
Defines link column.
# Slots
# default
slot
Use this slot to set the header caption
# Properties
# Optional Properties
Name | Type | Description | Default |
---|---|---|---|
field | object |string |function | Defines a column data field | undefined |
width | number |string | Defines a default column width | undefined |
min-width | number |string | Defines a column min width | undefined |
max-width | number |string | Defines a column max width | undefined |
column-type | object |string |function | Defines a column type | undefined |
column-style | object |string |function | Defines a column style. Same as the style property of the JS API. | undefined |
caption | string |function | Defines a header caption | '' |
disabled | boolean |function | Defines disabled. You can also control each record by specifying a function. | false |
colspan | number |string | Defines the layout colspan. This property can be used when defining in the layout-header and layout-body slots. | undefined |
filter | string |function | Defines a vue filter name | undefined |
header-action | object |string |function | Defines a column header action. Same as the headerAction property of the JS API. | undefined |
header-field | string | Defines a column header data field | undefined |
header-icon | object |string | Defines a header icon | undefined |
header-style | object |string |function | Defines a column header style. Same as the headerStyle property of the JS API | undefined |
header-type | object |string |function | Defines a column header type. Same as the headerStyle property of the JS API | undefined |
href | string |function | Defines a href | undefined |
icon | object |string |function | Defines an icon. Same as the icon property of the JS API. | undefined |
message | object |string |function | Defines a message generation method. Same as the message property of the JS API. | undefined |
rowspan | number |string | Defines the layout rowspan. This property can be used when defining in the layout-header and layout-body slots. | undefined |
sort | boolean |string |function | Defines a sort. See "Sort by Column" for detail. | undefined |
target | string | Defines an anchor target | undefined |
# Methods
Name | Return Type | Description |
---|---|---|
invalidate | --- | Redraws the whole grid. |
+ ← + + CGridLayoutRow + + CGridMenuColumn + + → +
# CGridMenuColumn
Defines select menu column.
# Slots
# default
slot
Use this slot to set the header caption
# Properties
# Optional Properties
Name | Type | Description | Default |
---|---|---|---|
field | object |string |function | Defines a column data field | undefined |
width | number |string | Defines a default column width | undefined |
min-width | number |string | Defines a column min width | undefined |
max-width | number |string | Defines a column max width | undefined |
column-style | object |string |function | Defines a column style. Same as the style property of the JS API. | undefined |
caption | string |function | Defines a header caption | '' |
disabled | boolean |function | Defines disabled. You can also control each record by specifying a function. | false |
readonly | boolean |function | Defines readonly. You can also control each record by specifying a function. | false |
colspan | number |string | Defines the layout colspan. This property can be used when defining in the layout-header and layout-body slots. | undefined |
display-options | object |Array | Defines a menu options for display | undefined |
editor-options | object |Array |function | Defines a menu options for popup | undefined |
filter | string |function | Defines a vue filter name | undefined |
header-action | object |string |function | Defines a column header action. Same as the headerAction property of the JS API. | undefined |
header-field | string | Defines a column header data field | undefined |
header-icon | object |string | Defines a header icon | undefined |
header-style | object |string |function | Defines a column header style. Same as the headerStyle property of the JS API | undefined |
header-type | object |string |function | Defines a column header type. Same as the headerStyle property of the JS API | undefined |
icon | object |string |function | Defines an icon. Same as the icon property of the JS API. | undefined |
message | object |string |function | Defines a message generation method. Same as the message property of the JS API. | undefined |
options | object |Array | Defines a menu options | undefined |
rowspan | number |string | Defines the layout rowspan. This property can be used when defining in the layout-header and layout-body slots. | undefined |
sort | boolean |string |function | Defines a sort. See "Sort by Column" for detail. | undefined |
# Methods
Name | Return Type | Description |
---|---|---|
invalidate | --- | Redraws the whole grid. |
+ ← + + CGridLinkColumn + + CGridPercentCompleteBarColumn + + → +
# CGridPercentCompleteBarColumn
Defines percent complete bar column.
# Slots
# default
slot
Use this slot to set the header caption
# Properties
# Optional Properties
Name | Type | Description | Default |
---|---|---|---|
field | object |string |function | Defines a column data field | undefined |
width | number |string | Defines a default column width | undefined |
min-width | number |string | Defines a column min width | undefined |
max-width | number |string | Defines a column max width | undefined |
column-style | object |string |function | Defines a column style. Same as the style property of the JS API. | undefined |
action | object |string |function | Defines an action | undefined |
caption | string |function | Defines a header caption | '' |
colspan | number |string | Defines the layout colspan. This property can be used when defining in the layout-header and layout-body slots. | undefined |
filter | string |function | Defines a vue filter name | undefined |
formatter | function | Defines a formatter | undefined |
header-action | object |string |function | Defines a column header action. Same as the headerAction property of the JS API. | undefined |
header-field | string | Defines a column header data field | undefined |
header-icon | object |string | Defines a header icon | undefined |
header-style | object |string |function | Defines a column header style. Same as the headerStyle property of the JS API | undefined |
header-type | object |string |function | Defines a column header type. Same as the headerStyle property of the JS API | undefined |
icon | object |string |function | Defines an icon. Same as the icon property of the JS API. | undefined |
max | number |string | Defines a max value | undefined |
message | object |string |function | Defines a message generation method. Same as the message property of the JS API. | undefined |
min | number |string | Defines a min value | undefined |
rowspan | number |string | Defines the layout rowspan. This property can be used when defining in the layout-header and layout-body slots. | undefined |
sort | boolean |string |function | Defines a sort. See "Sort by Column" for detail. | undefined |
# Methods
Name | Return Type | Description |
---|---|---|
invalidate | --- | Redraws the whole grid. |
+ ← + + CGridMenuColumn + + CGridRadioColumn + + → +
# CGridRadioColumn
Defines radio button column.
# Vue Template Structure
<div class="demo-grid small">
+ <c-grid
+ :data="records"
+ :frozen-col-count="1">
+ <c-grid-radio-column
+ field="c1"
+ width="100"
+ >
+ Radio1
+ </c-grid-radio-column>
+ <c-grid-radio-column
+ field="c2"
+ width="100"
+ >
+ Radio2
+ </c-grid-radio-column>
+ </c-grid>
+</div>
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
export default {
+ data() {
+ return {
+ records: [
+ { c1: true, c2: false },
+ { c1: false, c2: true },
+ { c1: false, c2: false },
+ { c1: false, c2: false },
+ { c1: false, c2: false },
+ { c1: false, c2: false },
+ { c1: false, c2: false },
+ { c1: false, c2: false },
+ { c1: false, c2: false },
+ { c1: false, c2: false },
+ ],
+ };
+ },
+};
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Slots
# default
slot
Use this slot to set the header caption
# Properties
# Optional Properties
Name | Type | Description | Default |
---|---|---|---|
field | object |string |function | Defines a column data field | undefined |
width | number |string | Defines a default column width | undefined |
min-width | number |string | Defines a column min width | undefined |
max-width | number |string | Defines a column max width | undefined |
column-style | object |string |function | Defines a column style. Same as the style property of the JS API. | undefined |
caption | string |function | Defines a header caption | '' |
disabled | boolean |function | Defines disabled. You can also control each record by specifying a function. | false |
readonly | boolean |function | Defines readonly. You can also control each record by specifying a function. | false |
check-action | function | Change the check action from the default. | undefined |
colspan | number |string | Defines the layout colspan. This property can be used when defining in the layout-header and layout-body slots. | undefined |
filter | string |function | Defines a vue filter name | undefined |
group | function | DEPRECATED! Use checkAction instead. Define a function that returns a radio group. | undefined |
header-action | object |string |function | Defines a column header action. Same as the headerAction property of the JS API. | undefined |
header-field | string | Defines a column header data field | undefined |
header-icon | object |string | Defines a header icon | undefined |
header-style | object |string |function | Defines a column header style. Same as the headerStyle property of the JS API | undefined |
header-type | object |string |function | Defines a column header type. Same as the headerStyle property of the JS API | undefined |
icon | object |string |function | Defines an icon. Same as the icon property of the JS API. | undefined |
message | object |string |function | Defines a message generation method. Same as the message property of the JS API. | undefined |
rowspan | number |string | Defines the layout rowspan. This property can be used when defining in the layout-header and layout-body slots. | undefined |
sort | boolean |string |function | Defines a sort. See "Sort by Column" for detail. | undefined |
# Methods
Name | Return Type | Description |
---|---|---|
invalidate | --- | Redraws the whole grid. |
# Available Vue Components
Component Name | Description | LINK |
---|---|---|
<c-grid> | Grid. | CGrid |
<c-grid-column> | Column definition to display in the grid. | CGridColumn |
<c-grid-column-group> | Definition of column group when multiple header is displayed. | CGridColumnGroup |
<c-grid-button-column> | Button column definition. | CGridButtonColumn |
<c-grid-check-column> | Checkbox column definition. | CGridCheckColumn |
<c-grid-input-column> | Input column definition. | CGridInputColumn |
<c-grid-menu-column> | Menu column definition. | CGridMenuColumn |
<c-grid-link-column> | Link column definition. | CGridLinkColumn |
<c-grid-icon-column> | Icon column definition. | CGridIconColumn |
<c-grid-percent-complete-bar-column> | Percent complete bar column definition. | CGridPercentCompleteBarColumn |
<c-grid-radio-column> | Radio button column definition. | CGridRadioColumn |
<c-grid-branch-graph-column> | Branch graph column definition. | CGridBranchGraphColumn |
<c-grid-layout-row> | Define advanced layout row. | CGridLayoutRow |
<c-grid-header> | Define advanced layout header. | CGridHeader |
+ ← + + API for Vue.js + + CGrid + + → +
# Define Headers and Columns
# Standard Column
You can define the behavior and appearance of columns and headers cells by defining <c-grid-column>
in slot
of <c-grid>
.
<div class="demo-grid middle">
+ <c-grid :data="records" frozen-col-count="1">
+ <c-grid-column
+ field="personid"
+ width="100">
+ ID
+ </c-grid-column>
+ <c-grid-column
+ field="fname"
+ width="200">
+ First Name
+ </c-grid-column>
+ <c-grid-column
+ field="lname"
+ width="200">
+ Last Name
+ </c-grid-column>
+ <c-grid-column
+ :field="getBirthday"
+ width="200">
+ Birthday
+ </c-grid-column>
+ </c-grid>
+</div>
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
+ record object properties
+ {
+ personid: 'ID',
+ fname: 'First Name',
+ lname: 'Last Name',
+ email: 'Email',
+ birthday: 'birthday',
+ }
+ */
+const records = generatePersons(100);
+
+export default {
+ data() {
+ return {
+ records,
+ };
+ },
+ methods: {
+ getBirthday(rec) {
+ const dateTimeFormat = new Intl.DateTimeFormat("en-US", {
+ year: "numeric",
+ month: "numeric",
+ day: "numeric",
+ });
+ return dateTimeFormat.format(rec.birthday);
+ },
+ },
+};
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Multiple Header
To use multiple header, define <c-grid-column-group>
.
<div class="demo-grid middle">
+ <c-grid :data="records" frozen-col-count="1">
+ <c-grid-column
+ field="personid"
+ width="100">
+ ID
+ </c-grid-column>
+ <!-- multiple header -->
+ <c-grid-column-group caption="Name">
+ <c-grid-column
+ field="fname"
+ width="200">
+ First Name
+ </c-grid-column>
+ <c-grid-column
+ field="lname"
+ width="200">
+ Last Name
+ </c-grid-column>
+ </c-grid-column-group>
+ <c-grid-column
+ :field="getBirthday"
+ width="200">
+ Birthday
+ </c-grid-column>
+ </c-grid>
+</div>
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const records = generatePersons(100);
+
+export default {
+ data() {
+ return {
+ records,
+ };
+ },
+ methods: {
+ getBirthday(rec) {
+ const dateTimeFormat = new Intl.DateTimeFormat("en-US", {
+ year: "numeric",
+ month: "numeric",
+ day: "numeric",
+ });
+ return dateTimeFormat.format(rec.birthday);
+ },
+ },
+};
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+ ← + + Available Vue Components + + Advanced Layout + + → +
# API for Vue.js
# Available Vue Components
Please refer Available Vue Components
# Template
<div class="demo-grid middle">
+ <c-grid
+ :data="records"
+ :frozen-col-count="1">
+ <!-- define checkbox -->
+ <c-grid-check-column
+ field="check"
+ width="50" />
+ <c-grid-column
+ field="personid"
+ width= "85"
+ >
+ ID
+ </c-grid-column>
+ <!-- multiple header -->
+ <c-grid-column-group
+ caption="Name">
+ <c-grid-input-column
+ field="fname"
+ width="20%"
+ min-width="150"
+ >
+ First Name
+ </c-grid-input-column>
+ <c-grid-input-column
+ field="lname"
+ width= "20%"
+ min-width="150"
+ >
+ Last Name
+ </c-grid-input-column>
+ </c-grid-column-group>
+ <!-- button -->
+ <c-grid-button-column
+ caption="SHOW REC"
+ width="120"
+ @click="onClickRecord"
+ />
+ </c-grid>
+</div>
+
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
export default {
+ data() {
+ return {
+ records,
+ };
+ },
+ methods: {
+ onClickRecord(rec) {
+ alert(JSON.stringify(rec));
+ },
+ },
+};
+
2
3
4
5
6
7
8
9
10
11
12
+ ← + + API + + Available Vue Components + + → +