Skip to content

Commit

Permalink
add custom column example
Browse files Browse the repository at this point in the history
  • Loading branch information
sgratzl committed Mar 25, 2020
1 parent 40bbd8e commit acaca1f
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
60 changes: 60 additions & 0 deletions demo/customColumn.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>LineUp Builder Test</title>

<link href="./LineUpJS.css" rel="stylesheet">
<link href="./demo.css" rel="stylesheet">
<style>
.lu-action-my-action::before {
content: "My";
}
</style>
</head>
<body>
<script src="./LineUpJS.js"></script>

<script>
window.onload = function () {
const arr = [];
const cats = ['c1', 'c2', 'c3'];
for (let i = 0; i < 100; ++i) {
arr.push({
s: 'Row ' + i,
a: Math.random() * 10,
cat: cats[Math.floor(Math.random() * 3)],
d: new Date(Date.now() - Math.floor(Math.random() * 1000000000000))
});
}
const b = LineUpJS.builder(arr);

class MyStringColumn extends LineUpJS.StringColumn {

}
Reflect.decorate([
LineUpJS.toolbar('my')
], MyStringColumn);

b.registerColumnType('my', MyStringColumn);
b.registerToolbarAction('my', {
title: 'My Action',
onClick: () => {
window.alert('clicked');
},
options: {
mode: 'menu+shortcut'
}
})

b.column({
type: 'my',
column: 's'
});

const lineup = b.build(document.body);
};
</script>

</body>
</html>
4 changes: 2 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function resolveToolbarActions(col: Column, keys: string[], lookup: IToolbarLook
if (lookup.hasOwnProperty(key)) {
actions.push(<IToolbarAction>lookup[key]);
} else {
console.warn('cannot find: ', col.desc.type, key);
console.warn(`cannot find toolbar action of type: "${col.desc.type}" with key "${key}"`);
}
});
return actions;
Expand All @@ -214,7 +214,7 @@ function resolveToolbarDialogAddons(col: Column, keys: string[], lookup: IToolba
if (lookup.hasOwnProperty(key)) {
actions.push(<IToolbarDialogAddon>lookup[key]);
} else {
console.warn('cannot find: ', col.desc.type, key);
console.warn(`cannot find toolbar dialog addon of type: "${col.desc.type}" with key "${key}"`);
}
});
return actions;
Expand Down

0 comments on commit acaca1f

Please sign in to comment.