Skip to content

Commit c00f865

Browse files
committed
Example column working
1 parent c0744fa commit c00f865

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/index.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ function fmtCodepoint(cell: CellComponent) {
4444
return `U+${val.toUpperCase()}`;
4545
}
4646

47+
function fmtExampleString(cell: CellComponent) {
48+
const val = cell.getValue() as string;
49+
if (!val) {
50+
return "";
51+
}
52+
const codepoints = val.split(" ").map((cp) => parseInt(cp, 16));
53+
return String.fromCodePoint(...codepoints);
54+
}
55+
4756
function imgTooltipFn(imgType: string) {
4857
return function (e: MouseEvent, cell: CellComponent, onRendered: any) {
4958
var value = cell.getValue();
@@ -243,7 +252,14 @@ async function main() {
243252
},
244253
{
245254
field: "code",
255+
formatter: fmtExampleString,
246256
headerFilter: "input",
257+
headerFilterFunc: (headerValue, rowValue, rowData, filterParams) => {
258+
if (!headerValue || headerValue.length != 1) return true;
259+
const headerInt = headerValue.codePointAt(0);
260+
const headerHex = headerInt.toString(16).toUpperCase().padStart(4, "0");
261+
return headerHex == rowData.code;
262+
},
247263
headerHozAlign: "center",
248264
hozAlign: "center",
249265
responsive: 2,
@@ -280,7 +296,7 @@ async function main() {
280296
},
281297
{
282298
title: "Name",
283-
field: "sort",
299+
field: "name",
284300
formatter: "link",
285301
formatterParams: {
286302
labelField: "name",

0 commit comments

Comments
 (0)