<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>ZingGrid: Docs Getting Started</title> <!--Script Reference[1]--> <script nonce="undefined" src="https://cdn.zinggrid.com/zinggrid.min.js"></script> <style> html, body { height: 100%; width: 100%; margin: 0; padding: 0; } zing-grid[loading] { height: 277px; } </style> </head> <body> <!--Grid Component Placement[2]--> <zing-grid caption="Register Custom Editor" editor> <zg-data data='[{ "num": "3", "feet": "6", "inch": "0", "first": "Roberto", "last": "Aguayo", "col": "Florida State" }, { "num": "83", "feet": "6", "inch": "4", "first": "Braedon", "last": "Bowman", "col": "South Alabama" }, { "num": "67", "feet": "6", "inch": "6", "first": "Brett", "last": "Boyko", "col": "Nevada-Las Vegas" } ]'></zg-data> <zg-colgroup> <zg-column index="num" header="#"></zg-column> <zg-column index="first, last" header="Player"></zg-column> <zg-column index="col" header="College"></zg-column> <zg-column index="feet, inch" header="Height"> [[index.feet]]" [[index.inch]]' </zg-column> </zg-colgroup> </zing-grid> <script> ZingGrid.setLicense(['26ccbfec16b8be9ee98c7d57bee6e498']); // window:load event for Javascript to run after HTML // because this Javascript is injected into the document head window.addEventListener('load', () => { // Javascript code to execute after DOM content // hooks for editor let editor = { init($cell, editorField) { let oDOMInput = document.createElement('input'); oDOMInput.type = 'text'; oDOMInput.autoComplete = 'off'; oDOMInput.ariaInvalid = false; editorField.appendChild(oDOMInput); }, onOpen($cell, editorField, mData) { let oDOMInput = editorField.querySelector('input'); if (!mData) { mData = editorField.value || ''; } oDOMInput.value = String(mData); }, onClose(editorField) { console.log('close'); return 'Edited: ' + editorField.querySelector('input').value; }, }; // Register Editor ZingGrid.registerEditor(editor, 'prependEdited'); // Assign Editor let zgRef = document.querySelector('zing-grid'); zgRef.executeOnLoad(() => { let zgColRef = document.querySelector('zg-column[index="col"]'); zgColRef.editor = 'prependEdited'; }); }); </script> </body> </html>
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>ZingGrid: Docs Getting Started</title> <!--Script Reference[1]--> <script src="https://cdn.zinggrid.com/zinggrid.min.js"></script> </head> <body> <!--Grid Component Placement[2]--> <zing-grid caption="Register Custom Editor" editor> <zg-data data='[{ "num": "3", "feet": "6", "inch": "0", "first": "Roberto", "last": "Aguayo", "col": "Florida State" }, { "num": "83", "feet": "6", "inch": "4", "first": "Braedon", "last": "Bowman", "col": "South Alabama" }, { "num": "67", "feet": "6", "inch": "6", "first": "Brett", "last": "Boyko", "col": "Nevada-Las Vegas" } ]'></zg-data> <zg-colgroup> <zg-column index="num" header="#"></zg-column> <zg-column index="first, last" header="Player"></zg-column> <zg-column index="col" header="College"></zg-column> <zg-column index="feet, inch" header="Height"> [[index.feet]]" [[index.inch]]' </zg-column> </zg-colgroup> </zing-grid> </body> </html>
html, body { height: 100%; width: 100%; margin: 0; padding: 0; }
// window:load event for Javascript to run after HTML // because this Javascript is injected into the document head window.addEventListener('load', () => { // Javascript code to execute after DOM content // hooks for editor let editor = { init($cell, editorField) { let oDOMInput = document.createElement('input'); oDOMInput.type = 'text'; oDOMInput.autoComplete = 'off'; oDOMInput.ariaInvalid = false; editorField.appendChild(oDOMInput); }, onOpen($cell, editorField, mData) { let oDOMInput = editorField.querySelector('input'); if (!mData) { mData = editorField.value || ''; } oDOMInput.value = String(mData); }, onClose(editorField) { console.log('close'); return 'Edited: ' + editorField.querySelector('input').value; }, }; // Register Editor ZingGrid.registerEditor(editor, 'prependEdited'); // Assign Editor let zgRef = document.querySelector('zing-grid'); zgRef.executeOnLoad(() => { let zgColRef = document.querySelector('zg-column[index="col"]'); zgColRef.editor = 'prependEdited'; }); });