turbogrid

                            // global
                            const TG = window.turbogrid;
                            const { Grid, Util } = window.turbogrid;
                            // cjs
                            const TG = require("turbogrid");
                            const { Grid, Util } = require("turbogrid");
                            // esm
                            import TG from "turbogrid";
                            import { Grid, Util } from "turbogrid";
                        
Grid(container)
Creates a new grid instance for the specified container.
The container argument can be a CSS selector, a DOM element, or an options object that includes a container property.

                            //selector
                            const grid = new Grid(".container");
                            //or element
                            const container = document.querySelector(".container");
                            const grid = new Grid(container);
                            //or options with container
                            const grid = Grid({
                                container,
                                ... other options
                            });
                        
Methods
setData(data)
Sets the grid data. See the data structure section for details.
The data object reads columns, rows, rowsLength, and options. rowsLength is useful when the total row count is known before all rows are loaded.

                            grid.setData({
                                columns: [],
                                rows: []
                            });
                        
getData()
Returns the current grid data object.

                            const data = grid.getData();
                        
setDataSnapshot(data)
Loads data from a plain snapshot by stripping private tg_* fields and rebuilding normalized tree state for rows and columns.

                            grid.setDataSnapshot(data);
                        
getItemSnapshot(item[, keysSettings])
Returns a sanitized snapshot of a row or column item.
When keysSettings is omitted, private fields are removed. When keysSettings is provided, keys set to true are included explicitly and keys set to false are excluded.

                            const rowSnapshot = grid.getItemSnapshot(rowItem);
                            const rowSnapshot2 = grid.getItemSnapshot(rowItem, {
                                id: true,
                                name: true
                            });
                        
setOption(options)
Sets one or more grid options. See options for available settings.
Supports both setOption(optionKey, optionValue) and setOption(optionsObject).

                            //set multiple options
                            grid.setOption({
                                optionKey1: optionValue1,
                                optionKey2: optionValue2
                            });
                            //set single option
                            grid.setOption(optionKey, optionValue);
                        
getOption([name])
Returns the current option value for name, or the full options object when no name is provided.
Returns undefined for unknown keys.

                            //get all options
                            const options = grid.getOption();
                            //get single option
                            const optionValue = grid.getOption(optionKey);
                        
setFormatter(formatters)
Registers or overrides grid formatters.
Supports both setFormatter(type, handler) and setFormatter(formatterMap). Registered handlers run with the grid instance as this.

                            //set multiple formatters
                            grid.setFormatter({
                                string: function(value, rowItem, columnItem, cellNode) {
                                    return value;
                                }
                            });

                            //set single formatter
                            grid.setFormatter("string", formatterHandler);
                        
Built-in cell formatters: string, number, date, icon, blank, checkbox, tree, null
Built-in header formatter: header
Formatter signature:

                            function(value, rowItem, columnItem, cellNode) { 
                                // value is formatted by null formatter
                                // get original value:
                                const originalValue = rowItem[columnItem.id];
                                const rowIndex = rowItem.tg_index;
                                const columnIndex = columnItem.tg_index;
                                // using default formatter returns:
                                const defaultFormatter = this.getDefaultFormatter("[formatter-name]");
                                return defaultFormatter(value + " new text", rowItem, columnItem, cellNode)
                            } 
                        
getFormatter(type)
Returns the formatter function registered for the specified type, bound to the current grid instance.

                            const stringFormatter = grid.getFormatter("string");
                        
getDefaultFormatter([type])
Returns the built-in formatter function for the specified type.
Falls back to the built-in string formatter when the requested type is missing.

                            const treeFormatter = grid.getDefaultFormatter("tree");
                        
bind(eventType, handler[, options])
Binds an event handler to the grid. See events for supported event types.
eventType can be a single event name, multiple names separated by spaces, or an object map of event names to handlers. Namespaced events such as onUpdated.demo are supported.
Use options such as { once: true } to control listener behavior.

                            grid.bind("onUpdated", function(e, d){
                                //console.log(d);
                            });
                        
Demo Events
once(eventType, handler)
Binds a handler that runs once and is removed after the first trigger.
Accepts the same eventType formats as bind.

                            grid.once("onUpdated", function(e, eventData){
                                //console.log(eventData);
                            });
                        
unbind([eventType][, handler][, options])
Removes previously bound event handlers from the grid.
Call without arguments to remove all handlers, with an event name or namespace to remove matching handlers, or with both eventType and handler to remove a specific binding.

                            grid.unbind();
                            grid.unbind("onUpdated");
                            grid.unbind("onUpdated", handler);
                        
trigger(eventType, eventData)
Triggers an event and calls all bound handlers with the provided event data.
Handlers receive the event object first and eventData as the second argument.

                            this.trigger(eventType, eventData);
                        
getAllEvents()
Returns all supported event types.

                            const allEventTypes = grid.getAllEvents();
                        
Demo Events
render()
Schedules a render pass using the current data, options, and formatters.
Repeated calls in the same tick are merged, so render is safe to call after batched updates.

                            grid.render();
                        
rerender()
Forces a full rebuild of the grid structure and renders it again.

                            grid.rerender();
                        
resize([w, [h]])
Recalculates the layout and optionally applies a new size.
Supports resize(), resize(width, height), and resize(styleMap) where styleMap is applied to the grid holder.

                            grid.resize();
                            grid.resize(600, 400);
                        
Demo Resize
destroy()
Destroys the grid instance and removes generated DOM, observers, and event bindings.

                            grid.destroy();
                        
getColumnItem(columnIndex) getColumnItemById(id) getColumnItemBy(key, value) getRowItem(rowIndex) getRowItemById(id) getRowItemBy(key, value)
The rowIndex and columnIndex parameters support several input forms:
  1. If the parameter is a Number, the grid looks up the row or column by index. Negative indexes are supported, so -1 resolves to the last item.
  2. If the parameter is a String, the grid searches all items for a matching row or column id.
  3. If the parameter is an Object, the grid inspects these properties:
    • If the object has a tg_index property, the grid looks up the row or column by index first.
    • If the object has an id property of type String, the grid searches all items for a matching id.

                            const columnItem = grid.getColumnItem(columnIndex);
                            const columnItemById = grid.getColumnItemById("id_123");
                            const rowItem = grid.getRowItem(rowIndex);
                            const rowItemById = grid.getRowItemById("id_123");
                            const rowItem = grid.getRowItem(123);
                            const rowItem = grid.getRowItem("id_123");
                            const rowItem = grid.getRowItemBy("id", "id_123");
                            const rowItem = grid.getRowItemBy("key", "value");
                        
showLoading() hideLoading() setLoading(loading)
Shows, hides, or customizes the built-in loading overlay.
loading can be plain content, a DOM node, a factory function that receives the loading container, or a default-loading options object such as { size, color, fast }.

                            grid.showLoading();
                            grid.hideLoading();
                            grid.setLoading("Loading ...");
                            grid.setLoading(function(container) {
                                return document.createElement("div");
                            });
                        
showMask([styleMap]) hideMask()
Shows or hides the interaction-blocking mask overlay.
Pass styleMap to override mask styles such as opacity or background color.

                            grid.showMask();
                            grid.showMask({
                                opacity: 0.3
                            });

                            grid.hideMask();
                        
expandAllRows() collapseAllRows() toggleAllRows()
Expands, collapses, or toggles all tree rows.

                            grid.expandAllRows();
                            grid.collapseAllRows();
                            grid.toggleAllRows();
                        
expandRow(rowIndex) collapseRow(rowIndex) toggleRow(rowIndex)
Expands, collapses, or toggles a specific row.
If the target row is a group with no loaded subs yet, expandRow may trigger onRowSubsRequest so child rows can be loaded lazily.

                            grid.expandRow(rowIndex);
                            grid.collapseRow(rowIndex);
                            grid.toggleRow(rowIndex);
                        
expandRowLevel(level)
Expands rows up to the specified tree level.

                            grid.expandRowLevel(level);
                        
exportData([keysSettings])
Returns export-ready columns and rows with private fields removed, optionally filtered by keysSettings.
In keysSettings, true forces a key to be included and false excludes it.

                            const exportedData = grid.exportData();
                            const exportedData = grid.exportData({
                                the_key_need: true,
                                key_key_no_need: false
                            });
                        
Demo Export
setRowSubs(rowIndex, subs)
Replaces the child rows for the specified parent row.
Passing an array of subs updates the row tree immediately and marks the parent row as expanded.

                            const subs = [{name:"row1"},{name:"row2"}];
                            grid.setRowSubs(rowIndex, subs);
                        
setColumns(columnList)
Replaces the current top-level columns and triggers a full rerender.

                            const columns = [{id:"name", name:"Name"}];
                            grid.setColumns(columns);
                        
setRows(rowList)
Replaces the current top-level rows with a new row list.
Use setRows when only the row tree changes. Use setData when columns or options also need to be replaced.

                            const rows = [{name:"row1"},{name:"row2"}];
                            grid.setRows(rows);
                        
getRows() getColumns() getViewRows() getViewColumns([all]) getViewRowItem(viewRowIndex) getViewColumnItem(viewColumnIndex)
getRows and getColumns return the source top-level data.
A view index is the current visible order after filtering, collapsing, sorting, and column visibility changes.
getViewColumns(true) also includes visible group columns in the returned list.

                            const rows = grid.getRows();
                            const columns = grid.getColumns();
                            const viewRows = grid.getViewRows();
                            const viewColumns = grid.getViewColumns();
                            const viewRowItem = grid.getViewRowItem(0);
                            const viewColumnItem = grid.getViewColumnItem(0);
                        
addRow(rowInfo[, parent, position, scrollTo = true]) deleteRow(rowIndex)
Adds a row or deletes one or more rows.
parent can be a row reference, row index, or row id. position inserts at a specific child index, and scrollTo defaults to true so the new row is brought into view.

                            grid.addRow({
                                id: "id1",
                                name: "row item"
                            });
                            grid.addRow(["Row 1", "Row 2"]);
                            grid.addRow(["Row 1", "Row 2"], parentIndex);
                            grid.addRow("Row Before","level_0", 0);
                            grid.deleteRow(2);
                            grid.deleteRow([1, 2]);
                        
moveRowsToTop(rowList) moveRowsUp(rowList) moveRowsDown(rowList) moveRowsToBottom(rowList) moveSelectedRowsToTop() moveSelectedRowsUp() moveSelectedRowsDown() moveSelectedRowsToBottom() moveRows(rowList, offset)
offset: values less than 0 move rows up, and values greater than 0 move rows down.
rowList can be a single row or a list of rows. The move is ignored when offset is 0 or when all visible rows are included.

                            grid.moveRowsToTop(["row_id1", "row_id2"]);
                            grid.moveRowsUp(["row_id1", "row_id2"]);
                            grid.moveRowsDown(["row_id1", "row_id2"]);
                            grid.moveRowsToBottom(["row_id1", "row_id2"]);
    
                            grid.moveSelectedRowsToTop();
                            grid.moveSelectedRowsUp();
                            grid.moveSelectedRowsDown();
                            grid.moveSelectedRowsToBottom();

                            grid.moveRows(["row_id"], -1);
                            grid.moveRows(["row_id"], -2);
                            grid.moveRows("row_id", 1);
                        
selectAll([selected = true])
Selects or clears all selectable rows.
In single-select mode, selectAll(true) is ignored.

                            grid.selectAll();
                            grid.selectAll(false);
                        
setRowSelected(rowInfo[, settings])
Updates the selected state of one or more rows.
In multi-select mode, pass false as the only argument to clear all, pass false as the second argument to unselect specific rows, or pass an event with Shift pressed to select a range from the previous selection.

                            grid.setRowSelected(rowIndex);
                            grid.setRowSelected(rowIndex, false);
                            grid.setRowSelected(false);
                        
getSelectedRow() getSelectedRows()
getSelectedRow returns the first selected row or null.
getSelectedRows always returns an array sorted by selection order.

                            const selectedRow = grid.getSelectedRow();
                            const selectedRows = grid.getSelectedRows();
                        
setRowHover(rowIndex, hover)
Sets whether the specified row is hovered.

                            grid.setRowHover(rowIndex, true);
                            grid.setRowHover(rowIndex, false);
                        
setRowState(rowIndex, state, value = true)
Sets a custom row state and toggles the CSS class tg-[state] on rendered row nodes.

                            grid.setRowState(rowIndex, "selected", true);
                            grid.setRowState(rowIndex, "warning", true);
                            grid.setRowState(rowIndex, "warning", false);
                        
setSortColumn(sortColumn) removeSortColumn()
setSortColumn accepts the same input forms as getColumnItem.
Calling setSortColumn repeatedly with the same column toggles sortAsc. removeSortColumn clears the current sort state.

                            grid.setSortColumn(sortColumn);
                            grid.removeSortColumn();
                        
setColumnWidth(columnIndex, width)
Updates a column width at runtime.
width is rounded to an integer, clamped to 0 or greater, and updates the column width, minWidth, and maxWidth together.

                            grid.setColumnWidth(columnIndex, width);
                        
showColumn(columnIndex) hideColumn(columnIndex)
Shows or hides one or more columns.
Accepts the same input forms as getColumnItem, including lists.

                            grid.showColumn(columnIndex);
                            grid.hideColumn(columnIndex);
                            grid.showColumn([1, 3]);
                            grid.hideColumn([1, 3]);
                        
addColumn(columnInfo[, parent, position, scrollTo = true]) deleteColumn(columnIndex)
Adds a column or deletes one or more columns.
parent can be a column reference, column index, or column id. position inserts at a specific child index, and scrollTo defaults to true so the new column is brought into view.

                            grid.addColumn({
                                id: "id1",
                                name: "column item"
                            });
                            grid.addColumn(["Column 1", "Column 2"]);
                            grid.addColumn(["Column 1", "Column 2"], parentIndex);
                            grid.addColumn("Column Before","level_0",0);
                            grid.deleteColumn(2);
                            grid.deleteColumn([1, 2]);
                        
scrollToRow(rowIndex) scrollToFirstRow() scrollToLastRow() scrollToColumn(columnIndex) scrollToFirstColumn() scrollToLastColumn(end) scrollToCell(rowIndex, columnIndex)
Scrolls directly to the specified row, column, or cell.
scrollToLastColumn(end) skips the trailing blank filler column unless end is true.

                            grid.scrollToRow(rowIndex);
                            grid.scrollToColumn(columnIndex);
                            grid.scrollToCell(rowIndex, columnIndex);
                        
Demo Scroll
scrollRowIntoView(rowIndex) scrollColumnIntoView(columnIndex) scrollCellIntoView(rowIndex, columnIndex)
Scrolls just enough to bring the target row, column, or cell into view.

                            grid.scrollRowIntoView(rowIndex);
                            grid.scrollColumnIntoView(columnIndex);
                            grid.scrollCellIntoView(rowIndex, columnIndex);
                        
Demo Scroll
setScrollTop(top) setScrollLeft(left) getScrollTop() getScrollLeft()
Sets or returns the current scroll positions.

                            grid.setScrollTop(200);
                            grid.setScrollLeft(200);
                            const st = grid.getScrollTop();
                            const sl = grid.getScrollLeft();
                        
Demo Scroll
updateRow(rowIndex[, rowData]) updateCell(rowIndex, columnIndex[, cellValue]) update() flushBody() flushSort() flushRow(viewRowIndex) flushRowFrom(viewRowIndex) flushColumn(viewColumnIndex) flushColumnFrom(viewColumnIndex) flushCell(viewRowIndex, viewColumnIndex)
updateRow merges partial rowData into the existing row.
updateCell reads rowIndex and columnIndex using the normal row and column lookup rules. Omitting rowData or cellValue rerenders the existing data.
flushBody clears all cached row renders. flushSort clears the row cache used after sorting.
flushRow, flushRowFrom, flushColumn, flushColumnFrom, and flushCell use view indexes (tg_view_index), not source indexes.

                            grid.update();
                            grid.flushBody();
                            grid.flushSort();
                            grid.flushRow(viewRowIndex);
                            grid.flushRowFrom(viewRowIndex);
                            grid.flushColumn(viewColumnIndex);
                            grid.flushColumnFrom(viewColumnIndex);
                            grid.flushCell(viewRowIndex, viewColumnIndex);
                            grid.updateRow(rowIndex);
                            grid.updateRow(rowIndex, rowData);
                            grid.updateCell(rowIndex, columnIndex);
                            grid.updateCell(rowIndex, columnIndex, cellValue);
                        
Demo Flush
getScrollbarWidth()
Returns 0 when no vertical scrollbar is present; otherwise returns scrollbarSize when hasVScroll is true.
getScrollbarHeight()
Returns 0 when no horizontal scrollbar is present; otherwise returns scrollbarSize when hasHScroll is true.

                            const sbw = grid.getScrollbarWidth();
                            const sbh = grid.getScrollbarHeight();
                        
getScrollViewWidth() getScrollViewHeight()
Scroll view size equals scroll pane size minus scrollbar size.

                            const svw = grid.getScrollViewWidth();
                            const svh = grid.getScrollViewHeight();
                        
getScrollPaneWidth() getScrollPaneHeight()
Scroll pane size equals scroll view size plus scrollbar size.

                            const spw = grid.getScrollPaneWidth();
                            const sph = grid.getScrollPaneHeight();
                        
getColumnsLength(total)
Returns the number of visible columns by default. Pass true to include hidden columns.

                            const len = grid.getColumnsLength();
                            const totalLen = grid.getColumnsLength(true);
                        
getRowsLength(total)
Returns the number of visible rows by default. Pass true to include collapsed or filtered rows.

                            const len = grid.getRowsLength();
                            const totalLen = grid.getRowsLength(true);
                        
getRowsHeight()
Returns the total rendered height of all rows.

                            const totalHeight = grid.getRowsHeight();
                        
getRowHeight(rowIndex)
Returns the computed height of the specified row.

                            const rowHeight = grid.getRowHeight(rowIndex);
                        
getViewport()
Returns the current visible row and column index ranges.

                            const viewport = grid.getViewport();
                            // { rows, columns }
                        
find(selector[, container])
Finds nodes inside the grid root with a CSS selector.
Pass container to limit the query to a specific node inside the grid.

                            const nodes = grid.find(".selector-name");
                        
getRowNodes(rowIndex)
Returns the rendered DOM nodes for the specified row.
The return value is a Query collection, which is useful when the same row is rendered in multiple panes.

                            const rowNodes = grid.getRowNodes(rowIndex);
                        
getCellNode(rowIndex, columnIndex) getCellValue(rowItem, columnItem)
Returns a rendered cell node or resolves the raw cell value.
getCellValue returns rowItem[columnItem.id] before any formatter is applied.

                            const cellNode = grid.getCellNode(rowIndex, columnIndex);
                            const cellValue = grid.getCellValue(rowItem, columnItem);
                        
getHeaderItemNode(columnIndex)
Returns the header item node for the specified column.
Accepts the same input forms as getColumnItem.

                            const headerItemNode = grid.getHeaderItemNode(columnIndex);
                        
getColumnHeaderNode(columnIndex)
Returns the header container node for the specified column.
Accepts the same input forms as getColumnItem.

                            const columnHeaderNode = grid.getColumnHeaderNode(columnIndex);
                        
forEachColumn(callback) forEachRow(callback)
Iterates over each column or row and calls the provided callback.
The callback receives (item, index, parent) for each node in the tree.

                            grid.forEachColumn(function(column, index, parent) {
                                //
                            });
                            grid.forEachRow(function(row, index, parent) {
                                //
                            });
                        
isRowSelectable(rowItem)
Returns whether the row can be selected under the current rules.

                            const rowItem = grid.getRowItem(rowIndex);
                            if (grid.isRowSelectable(rowItem)) {
                                console.log("selectable");
                            }
                        
isRowLeaf(rowItem)
Returns whether the row is a leaf node.
highlightKeywordsFilter(rowItem, columns, keywords)
Helper used by rowFilter and highlightKeywords to match and mark keywords.
columns should be a list of column ids, and keywords is split on whitespace before matching.

                            grid.setOption({
                                rowFilter: function(rowItem) {
                                    return this.highlightKeywordsFilter(rowItem, ["name", "type"], "foo bar");
                                }
                            });
                        
onNextUpdated(handler)
Registers a one-time handler for the next onUpdated event.
This is equivalent to a one-shot listener for onUpdated.

                            grid.onNextUpdated(function(e, eventData){
                                //console.log(eventData);
                            });
                        
Data
Both columns and rows are same data structure (JSON/Tree-like):

                                    [{
                                        name: "item 1",
                                        subs: [{
                                            name : "item 2",
                                            subs: [{
                                                name : "item 3",
                                                subs: [{
                                                    ...
                                                }]
                                            }, ...]
                                        }, ...]
                                    }, ...]
                            

                            const data = {
                                columns : [...],
                                rows : [...]
                            };
                            grid.setData(data);
                        
columns
See columnProps for available column fields.

                            const columns = [{
                                id:"c1",
                                type : "string",
                                name:"Column Name 1"
                            }, {
                                id : "c2",
                                type : "number",
                                name : "Column Name 2"
                            }, {
                                id: "c3",
                                name: "Column Name 3",
                                subs: [{
                                    id: "c3_s1",
                                    name: "Column Name 3-1"
                                }, {
                                    id: "c3_s2",
                                    name: "Column Name 3-2"
                                }]
                            }];
                        
rows
See rowProps for available row fields.

                            const rows = [{
                                id : "r1",
                                name : "Row Name 1",
                                c1 : "string value 1",
                                c2 : 1,
                                c3_s1 : "value 3 - 1",
                                c3_s2 : "value 1 - 2"
                            }, {
                                id : "r2",
                                type : "group",
                                name : "Row Name 2",
                                c1 : "string value 2",
                                c2 : "value 2",
                                c3_s1 : "value 3 - 1",
                                c3_s2 : "value 1 - 2",
                                subs : [{
                                    id : "r3",
                                    type : "holding",
                                    name : "Row Name 3",
                                    c1 : "string value 3",
                                    c2 : 3,
                                    c3_s1 : "value 3 - 1",
                                    c3_s2 : "value 1 - 2"
                                }]
                            }];
                        
options
Applies options from the data payload. These values take precedence over setOption.

                            const data = {
                                options : {
                                    sortField : "name"
                                },
                                columns : columns,
                                rows : rows
                            };
                            grid.setData(data);
                        
rowsLength
Supports lazy row loading when rows are not provided but the total row count is known.

                                const data = {
                                    columns: columns,
                                    rowsLength: 50000
                                };
                                grid.setData(data);
                        
Options
className = "tg-turbogrid"
Customizes the root CSS class name used as the grid namespace.

                        grid.setOption({
                            className: "my-grid-class-name"
                        });
                        
theme = "[theme-name]"
Sets the theme name. Available values: default, lightblue, dark.
Demo Theme
rowHeight = 32
Sets the default row height in pixels.
rowCacheLength = 0 columnCacheLength = 0
Controls how many extra rows and columns are rendered outside the viewport as cache.
autoHeight = false
Automatically adjusts the grid height to fit its visible content.
headerVisible = true
Shows or hides the header area.
collapseAllVisible = true collapseAllOnInit = null
Controls whether collapse-all actions are shown and whether they run during initialization.
selectVisible = false selectAllVisible = true selectAllOnInit = null
Controls whether selection UI is shown and whether all rows are selected during initialization.
For selectAllOnInit: true selects all, false clears all, and null leaves the current state unchanged.
selectMultiple = true
rowNumberVisible = false
Shows or hides the built-in row number column.
rowNotFound = ''
Sets the empty-state content. Accepts an empty string, string, element, or function.
rowDragCrossLevel = true
Controls whether dragged rows can move across levels. Accepts a boolean or a function that returns the allowed drop list.
rowMoveCrossLevel = true
Controls whether move APIs can move rows across hierarchy levels.
sortField = ""
Specifies the field used for sorting comparisons.
sortAsc = true
true sorts ascending; false sorts descending.
sortBlankValueBottom = true
Controls how blank values are positioned during sorting.
true keeps rows with blank values at the bottom of the grid.
false places blank values at the bottom for descending sort and at the top for ascending sort.
sortOnInit = false
When true, the grid sorts by sortField during initialization.
sortIndicator = "h"
Sets the sort indicator style: "h" or "v".
sortComparers = {defaultSortComparers}
Provides custom comparer functions for sorting.
rowFilter rowFilteredSort = null
Filters rows before rendering and optionally sorts filtered matches.
columnTypes = {...}
Defines preset column types and id-to-type mappings.
rowProps =

                                {

                                    //selected: Boolean
                                    //collapsed: Boolean
                                
                                    //selectable : true
                                    //exportable: true
                                
                                    //sortFixed: [Boolean, String "top"]
                                
                                    // customize row style
                                    //classMap : [String, Array, Object]
                                    //styleMap : [String, Array, Object]
                                    //[columnId]ClassMap: [String, Array, Object]
                                    //[columnId]StyleMap: [String, Array, Object]
                                
                                    // row type for class name: group
                                    //type: String
                                
                                    //formatter: [String, Function]
                                
                                    //height: Number
                                
                                    //subs: Array
                                }
                        
columnProps =

                                {

                                    // require for showing header
                                    name: '',

                                    // for getting row value
                                    //id: String

                                    // expect to be a string, for example: "string", "number", "date" etc.
                                    //type: String

                                    // formatter expect to be a function, but also can be a string like type
                                    // priority is higher than type
                                    // be used for cell formatting
                                    //formatter: [String, Function]
                                    //headerFormatter: [String, Function]

                                    // comparer function when sort function(a, b, options)
                                    //comparer: [String, Function]

                                    // left (default) | center | right
                                    //align: String

                                    // customize column style
                                    //classMap: [String, Array, Object]
                                    //styleMap: [String, Array, Object]
                                    //headerClassMap: [String, Array, Object]
                                    //headerStyleMap: [String, Array, Object]

                                    //sortable: true
                                    //resizable: true
                                    //exportable: true

                                    //private: false

                                    // require for column resize
                                    minWidth: 81,
                                    maxWidth: 300

                                    //width: Number
                                    //height: Number

                                    //subs: Array
                                    
                                }
                        
frozenColumn = -1 frozenRow = -1 frozenBottom = false frozenRight = false frozenColumnMax = 10 frozenRowMax = 10 frozenRowHoverable = false
Configures frozen rows and columns. frozenRowHoverable enables hover styles and hover events on frozen rows.
Demo Frozen
scrollbarSize = 12 scrollbarSizeH = null scrollbarSizeV = null
Sets the base scrollbar thickness.
scrollbarRound = false
Enables rounded scrollbar styling.
scrollbarFade = false
Enables scrollbar fade-in and fade-out behavior.
scrollbarFadeTimeout = 1000
Sets the delay before faded scrollbars are hidden.
scrollbarType = "auto"
Sets the scrollbar preset: auto or mobile, where mobile enables fade and uses size 6.
scrollPaneMinWidth = 30
Sets the minimum width of the scroll pane.
scrollPaneGradient = false
Enables a gradient mask on the scroll pane edges.
rowDragVisible = false rowDragColumn = {...}
Enables built-in row drag handles and configures the drag column.
rowNumberWidth = 36 rowNumberFilter = null rowNumberColumn = {...}
Configures the built-in row number column.
selectColumn = {...} blankColumn = {...}
Configures the built-in private columns used for selection and layout filling.
highlightKeywords = {...}
Configures how matched keywords are extracted and wrapped with highlight markup.
textKey = "tg_text_" textGenerator = null highlightKey = "tg_highlight_" highlightPre = "<mark>" highlightPost = "</mark>"
textSelectable = false
Allows text selection inside grid cells.
bindWindowResize = false
Binds window resize and calls resize automatically.
bindContainerResize = false
Uses ResizeObserver to watch container size and call resize automatically.
Demo Resize
cellResizeObserver = null
Filters which cells are observed for size changes. Requires ResizeObserver.
Events
Event Type Event Data Example
onUpdated onFirstUpdated

                                        Object: viewport
                                    
Demo Events
onHeaderUpdated

                                        Object: {
                                            node: headerNode
                                        }
                                    
Demo Events
onSort

                                    Object: {
                                        e,
                                        columnItem,
                                        node: headerItemNode
                                    }
                                    
Demo Sort
onColumnAdded onColumnRemoved

                                        Array: [columnItem ...]
                                    
onColumnWidthChanged

                                        Object: columnItem
                                    
Demo Events
onRowAdded onRowRemoved

                                        Array: [rowItem ...]
                                    
onRowExpanded onRowCollapsed

                                        Object: rowItem
                                    
Demo Events
onRowSubsRequest

                                        Object: rowItem
                                    
onRowDragged

                                        Object: {
                                            e,
                                            rowItem
                                        }
                                    
onRowDropped

                                        Object: {
                                            rowItem,
                                            dragFrom,
                                            dragIndex,
                                            dropInto,
                                            dropIndex
                                        }
                                    
onRowMoved

                                        Array: [rowItem ...]
                                    
onRowMouseEnter onRowMouseLeave

                                        Object: {
                                            e,
                                            rowItem
                                        }
                                    
Demo Events
onSelectChanged

                                        Array [rowItem ...]
                                    
onCellUpdated

                                        Object: {
                                            value,
                                            rowItem,
                                            columnItem,
                                            node: cellNode
                                        }
                                    
Demo Events
onCellMouseEnter onCellMouseLeave

                                        Object: {
                                            e,
                                            rowItem,
                                            columnItem,
                                            rowNode,
                                            cellNode
                                        }
                                    
Demo Events
onClick onDblClick onContextMenu onMouseOver onMouseOut

                                        //on header
                                        Object: {
                                            e,
                                            columnItem,
                                            headerNode
                                        }
                                        //on body
                                        Object: {
                                            e,
                                            rowItem,
                                            columnItem,
                                            rowNode,
                                            cellNode
                                        }
                                    
Demo Events
onTouchStart onTouchMove onTouchEnd

                                        //on header
                                        Object: {
                                            e,
                                            columnItem?,
                                            headerNode?
                                        }
                                        //on body
                                        Object: {
                                            e,
                                            rowItem?,
                                            columnItem?,
                                            rowNode?,
                                            cellNode?
                                        }
                                    
Demo Touch
onScroll

                                        Object: {
                                            scrollLeft,
                                            scrollTop
                                        }
                                    
Demo Scroll
onScrollStateChanged

                                    Object: {
                                        hasHScroll,
                                        hasVScroll
                                    }
                                    
Demo Events
onMouseWheel

                                    Object: {
                                        e,
                                        deltaX,
                                        deltaY
                                    }
                                    
Demo Scroll
onResize

                                        Object: {
                                            previous: Object,
                                            width: Number, 
                                            height: Number
                                        }
                                    
Demo Resize
onLayout

                                        Object: {
                                            previous: Object,
                                            headerWidth: Number, 
                                            headerHeight: Number, 
                                            bodyWidth: Number, 
                                            bodyHeight: Number,
                                            scrollbarWidth: Number,
                                            scrollbarHeight: Number
                                        }
                                    
Demo Resize
onKeyDown

                                        Object: {
                                            e
                                        }
                                    
Demo Events
onDestroy
N/A
Demo Flush
Lifecycle
Phases Sub Phases Payload Capacity
create
Create styles and DOM structure inside the container.
Apply initial data.
Apply initial options.
Register initial formatters.
Bind initial event handlers.
low loading APIs

                                        const grid = new Grid(container);
                                        grid.setData(data);
                                        grid.setOption(options);
                                        grid.setFormatter(formatters);
                                        grid.bind("[event type]", handler);
                                    
render init options low all APIs

                                        grid.render();
                                        grid.rerender();
                                    
render header middle
render body render rows middle
render cells high
update
Update the grid body.
Update one or more rows.
Update one or more cells.

                                        grid.update();
                                        grid.updateRow(rowIndex, rowData);
                                        grid.updateCell(rowIndex, columnIndex, cellValue);
                                    
destroy remove all low none

                                        grid.destroy();
                                    
tg
"tg" is the grid prefix and internal namespace.
Common CSS class names:

                            .tg-pane {}
                            .tg-body{}
                            .tg-row{}
                            .tg-cell{}
                        
Common private properties:

                            //rowItem.tg_index
                            //rowItem.tg_level
                            //rowItem.tg_group
                        
These private properties are removed when calling exportData() or getItemSnapshot().
Row Item Properties (rowItem.tg_*)
Property Type Description
tg_index Number Global index of the row in the full data tree (including invisible rows).
tg_view_index Number Index of the row in the visible (view) list. Only set for visible rows.
tg_sub_index Number Index within the parent's subs array (includes invisible rows).
tg_list_index Number Index within the visible sub-list of the same parent.
tg_parent Object | undefined Reference to the parent row item. undefined for root-level rows.
tg_level Number Nesting level in the tree hierarchy. 0 for root-level rows.
tg_group Boolean true if the row has a subs array (is a group/parent node).
tg_subs_length Number Number of direct children in the row's subs array.
tg_frozen Boolean true if the row is in the frozen section.
tg_invisible Boolean true if the row was hidden by user via hideRow() or the invisible property.
tg_filtered Boolean true if the row was hidden by the rowFilter function.
tg_row_number String | Number The display row number (empty string if row number is not applicable).
tg_selected_index Number Sequential index indicating the order in which the row was selected.
tg_top Number Top position offset in pixels for rendering.
tg_height Number Actual rendered height of the row in pixels.
Column Item Properties (columnItem.tg_*)
Property Type Description
tg_index Number Global index of the column in the full column tree.
tg_view_index Number Index of the column in the visible (view) list. Only set for visible columns.
tg_sub_index Number Index within the parent group's subs array.
tg_list_index Number Index within the visible sub-list of the same parent group.
tg_parent Object | undefined Reference to the parent column group. undefined for top-level columns.
tg_group Boolean true if the column has a subs array (is a header group).
tg_subs_length Number Number of direct sub-columns in the group.
tg_frozen Boolean true if the column is in the frozen section.
tg_invisible Boolean true if the column was hidden by user via hideColumn() or the invisible property.
tg_width Number Actual rendered width of the column in pixels.
tg_left Number Left position offset of the column in pixels.
tg_height Number Height of the column header cell in pixels.
tg_layer Number Reverse level index for header layout (0 = bottom level). Used for grouped headers.
Usage example:

                            grid.setFormatter({
                                string: function(value, rowItem, columnItem, cellNode) {
                                    // access row properties
                                    const rowIndex = rowItem.tg_index;
                                    const level = rowItem.tg_level;
                                    const isFrozen = rowItem.tg_frozen;
                                    const isGroup = rowItem.tg_group;

                                    // access column properties
                                    const columnIndex = columnItem.tg_index;
                                    const columnWidth = columnItem.tg_width;

                                    return value;
                                }
                            });

                            grid.setOption({
                                rowFilter: function(rowItem) {
                                    // frozen rows are always visible
                                    if (rowItem.tg_frozen) {
                                        return true;
                                    }
                                    return rowItem.name.includes(keywords);
                                }
                            });