News in version
TreeGrid Gantt chart SpreadSheet Examples Documentation Download Development Licensing Prices References Contacts Buy Try it free
Documentation
Search in documentation
TreeGrid versions compatibility

Changes log (txt file) Using custom CSS from 13.3 to 14.0 Upgrading from 9.3 to 10.0 Upgrading from 5.9 to 6.0

Using in JavaScript frameworks

Angular Ember Express React Svelte Vue Other frameworks NodeJS server SalesForce LWC

Creating grid

Simple examples Basic information Creating grid Deleting grid Reloading grid Rendering grid Accessing grid by API

Data & communication
Data communication with server

Communication types AJAX communication AJAX SOAP envelope Submit communication Directly included data Data from JavaScript Cross domain / local load by JSONP Sessions (AJAX) Server response (AJAX) Synchronous communication (AJAX) Caching (AJAX) API (AJAX)

Download data

Settings for data download Layout XML structure Data XML structure

Upload data

Settings for data upload API for upload XML structure sent to server

Changing data from server

XML structure of download changes XML structure of request for a cell Synchronizing data with server

Input / output data formats

Complete list of tags Internal XML format Short XML format Extra short XML format DTD XML format JSON format

Cells
Cell basics

Cell type Cell format Dynamic format Dynamic type Cell value Reading / writing attributes by API Cell HTML Cell default Range or more values in one cell Cell with link URL Cell hint Cell tooltip / title Cell popup menu

Cell editing and changing values

Cell editability Dynamic editing Locking Defaults list Suggest list (auto complete) Tags input Changing cell value Mass cell change Clearing cells Editing cells Controlling <input> tag by JavaScript Input validation and restrictions Side checkbox Cell selecting

Calculations - cell formulas

Basics Formulas Mathematical functions Aggregate functions Special functions for actions Custom functions

Calculations - editable cell formulas

Basics Suggest list (auto complete) Defined names Actions for choosing cells Conditional functions Lookup functions Cell reference functions Logical functions Informational functions Mathematical functions Trigonometry functions Rounding numbers Number conversions String functions Date functions Summary functions Custom functions

Cell side buttons

Introduction Right side Button Left side Icon

Cell spanning

Column span Row span Dynamic spanning

Cell style and color

Basic grid style Sizing and scaling - responsive design Dynamic cell style attributes Cell CSS class Cell background color Dynamic cell border Cell HTML style Row color alteration Cell mouse cursor

Editable cell images

Insert image Edit image

Cell types
Automatic type - Auto String - Text, Lines & Pass
Number - Int & Float

Format Localization

Date and time - Date

Format Calendar component Dates dialog Localization

List & combo - Enum & Radio

Introduction Definition Related lists Enum specific Radio specific

Checkbox - Bool
Action button - Button

Introduction Basic clickable button Switch button Radio / tab button Menu button Combo switch button Combo radio / tab button Special Space rows with buttons

Panel with more buttons - Panel

Definition Standard fast panel Custom panel

HTML and special types

Html type EHtml type (editable) Icon type Abs type List type Editable Link type Editable Img type DropCols type Upload File type

Columns

Column basics Column index Column visibility Column visibility menu Column selecting Column tree Auto column tree Column position and moving Column adding and copying Column deleting Column width Column API

Rows
Row basics

Rows by functionality Rows by position Row name Row id Row index

Default rows

Description Example of default rows Example of changing default row Attributes

Row tree

Tree attributes Actions & API for expand / collapse

Row identification

Setting row id attribute Row id attribute in tree Row id created from cell values API for row ids

Row visibility
Row adding and copying

Five ways of adding rows to grid Adding and copying restrictions Adding new empty rows Copying existing rows

Row deleting Row moving and dragging Row selecting Row height Row API Space rows
Features
Sorting rows

Sort settings Controlling sort position Comparing strings Sorting actions Sorting API

Grouping rows to tree

Group settings Creating groups Comparing strings Created group rows <D Group='1'/> User interface to choose grouping Grouping actions and API

Filtering rows

Filter settings Comparing strings User interface to choose filter Filter actions and API

Searching in rows and cells

Search settings User interface for search Search actions and API

Printing grid

Print settings Choosing items to print Page size Print API

Print / export to PDF

Introduction Client side settings Printing options Client side API Server side API Data sent from client to server

Export to Excel or CSV

Introduction and export types Basic settings Styling export XLSX export Gantt export CSV export Old XLS / XHTML export Export API Communication with server Client export Server export

Import from Excel

Basic settings Sheets manipulation

Copy & paste rows via clipboard

Copy & paste permissions Copying to clipboard Pasting from clipboard

Master - detail grids

Introduction External master - detail grids Nested master - detail grids Synchronizing grids Other attributes for master - detail

Pivot tables

Pivot attributes & API Pivot formulas

External objects (custom JavaScript objects) Undo & Redo
Gantt and bar chart
Gantt objects

Gantt objects list Display settings Edit settings

Main bar

Definition of main bar and plans Main bar as Task Edit settings Main bar content and side html Tip on mouse hover Vertical position and height Style specific attributes API to manipulate Main bars Actions Side text (deprecated) Real Flow (deprecated)

Run bar

GanttRun Definition Extended definition Run bar as Task Edit settings Save format Selecting Run boxes Run box content and side html Tip on mouse hover Box identification Vertical position and height Style specific attributes Overlaid (Error) boxes Containers for more boxes Dragging - moving and resizing API to manipulate Run boxes Actions Run special formulas

Summary task

Main for Main Main for Run Editable Main Editable Run

Gantt icons - Flag & Point

Flag - icon with text Point - math points

Gantt display objects

Header - column captions Cell and column Background Vertical movable Line Mark & Progress line

Gantt zoom

Zoom options Chart size limits Zoom selection Paging in Gantt chart

Dependency, constraints & schedule

Introduction Data units Defining dependencies Dependency colors and shapes Changing dependencies Correcting dependencies Scheduling algorithm Project date constraints Task date constraints Critical path - Slack (Float)

Gantt calendars

Global base calendar Local calendar Calendar list Calendars dialog Other settings

Gantt resources

Resources list Resources assign Resources filter Resources calculations Availability chart Resource usage chart Generated resource usage chart

Gantt popup menu Gantt API
Line and XY points charts

Charts in grid cells Chart JSON definition Base chart settings Basic attributes Size Axis and caption Individual chart lines Data sources Visual settings API for standalone usage

Paging in large grids
Paging root rows

Paging types and attributes Auto adding root pages API for paging

Pager components

Side pager Side pager type Pages Side pager type Gantt Side pager type Custom Pager with navigation buttons & edit Pager as list of page indexes

Paging in tree

ChildPaging - load / render on expand MaxChildren - limit children count ChildParts - load / render on scroll

Paging columns

Paging types and attributes Auto adding column pages API for column paging

Server paging

Server paging for root rows Server communication in root paging Root paging in very large tables Server paging in tree Server communication in tree paging XML Request for Data in root paging XML Download Data in root paging XML Request for root Page / children XML Download root Page / children API for server paging

TreeGrid DLL/SO for server paging

Introduction Compatibility with TreeGrid control Using TreeGrid server DLL/SO ASP.NET C# ASP.NET VB PHP JSP Java TreeGrid server concepts Function reference Calculations

JSON menus and dialogs
JSON menu description JSON menu definition example
Menu settings

Base attributes Visual settings Key navigation Behavior Size and scroll

Menu item settings

Base attributes Clickable item Inactive caption Collapsible sub level Popup sub menu Columns Bool item Enum item Edit item

Custom menu in JavaScript

Show custom menu Custom menu position Custom menu advanced settings Custom menu JavaScript events Custom menu JavaScript methods

Calendar dialog Custom calendar & JavaScript events Custom dialog in JavaScript
Global grid settings
Grid size and scroll

Default behavior Maximize grid height and width Update size according to the content Let a user to control the grid size Widths of individual sections Other scrolling attributes and API

Media rules - responsive design
Languages

Language & regional setup (Text.xml) Translate texts dynamically Change language

Grid cursor - Focus & hover

Focused cell and row Focused cell range Move and copy focused cells Filling cell values by dragging Tabulator navigation Key navigation Cursor look - focus & hover

Selecting rows, cells and columns

Selecting base Selecting rows Selecting cells Selecting columns

Global settings

Status messages Configuration menus Configuration menu - options Configuration menu - columns Configuration menu - print / PDF Configuration menu - export Default toolbar Useful API function Help file

Animations

Animations base Row animations Column animations Cell animations Animations for undo / redo Animations for server side changes Dialog animations

Grid configuration in cookies
Mouse & key events & actions

List of event handler types TreeGrid mouse events Mouse event names Key and mouse button prefixes Touch event names Event targets Assigning event actions / callbacks Event action parameters Action name suffix Calling actions from JavaScript Creating custom actions Focused vs. Actual cell TreeGrid key events JavaScript API events

Mouse API event TreeGrid files
Debugging and testing

Debug window Automated testing

Print / export to PDF

TreeGrid documentation

Print and export of grid data to PDF document.

The printing to PDF shares setting with standard printing, see Choosing items to print and Page size.

In TreeGrid print menu it is possible to choose which columns or rows to print and set various printing options.
See Configuration menu for basic settings or Print menu for special settings.

The printing must be done on server side by some third party tool that converts HTML to PDF.
By default (since 14.0) we use (headless) Chrome for the HTML to PDF conversion.
The examples for PDF export using Chrome are included in default trial package for various server scripts (ASP.NET, PHP, JSP).

If the Chrome solution does not support your required features, we provide also two sample tools, WKHtmlToPdf as GPL command line tool using WebKit for rendering and EVOHtmlToPdf Converter as commercial ASP.NET library using IE for rendering. There can be use also any other HTML to PDF conversion tool.
These two tools and examples with them are in extra package at http://www.treegrid.com/treegrid/Download/TreeGridEvalPDFExport.zip

The PDF export works in this way:
1) On client side in main TreeGrid application a user chooses what and how will be printed (in menu, see ExportPDFCol and page size printing options).
2) The client side TreeGrid uploads the chosen setting and other configuration to server (the url is defined by ExportPDF_Url).
3) The server side script creates HTML of the same TreeGrid according to received configuration by PrintTreeGrid function. It shows simple page that loads TreeGrid script and creates the grid by PrintTreeGrid() instead of <bdo> or TreeGrid(). It should use the same data as the client side TreeGrid.
4) The server side script converts the HTML to PDF by some automation tool, e.g. WKHtmlToPdf or EVOHtmlToPdf.
5) The server side script returns the created binary PDF file as response of the client's request (received in point 2).

Client side settings

Settings to set up the communication from client side to server side

new 6.7 <treegrid,bdo> string

ExportPDF_Url

Destination for page that receives the grid configuration and creates and returns the binary PDF data.
This server URL should return the exported data as PDF file in HTTP content-type="application/pdf".
This communication is not done by AJAX, but always by hidden form, so it can be used even if no ActiveX is supported.
Export cannot use Soap or Get communication.
To this URL is uploaded actual grid configuration and the server script should create and return the exported data by itself.
new 6.7 <treegrid,bdo> string

ExportPDF_Data

["Data"]
The name of form input in that will be uploaded exported data or configuration to Export_Url
new 6.7 <treegrid,bdo> string

ExportPDF_Type

["settings"]
Which configuration will be sent to server for export, case insensitive.
Settings
To server will be send configuration (sorting, grouping, filters) and columns (positions, visibility and widths) and print settings in XML.
The server must generate the requested report in PDF according to the settings and stored data and return it to client.
Expanded
Sends ids of all expanded rows in <Cfg Expanded/> attribute, comma separated.
Changes
Sends modified rows - rows with set attribute Added, Deleted, Moved or Changed (modified values). The rows are sent in <Changes> tag.
When set, the export does not save the changes to server before export, but includes them in the export request.

This attribute supports also all other settings like Cookie or Data defined for _Type, see Upload_Typey.

PDF Export supports also other Upload_ attributes: ExportPDF_Flags (see Upload_Flags), ExportPDF_Attrs (see Upload_Attrs), ExportPDF_Format (see Upload_Format) and ExportPDF_XML (see xxx_XML).

Printing options

Settings specific to PDF chosen on client side and used on server side
Other printing setting are described at Choosing items to print and Page size

new 6.7 chg 9.0 <Cfg> int

ExportPDFCols

[2]
If and which menu will be shown before doing export to PDF.
0 - no menu
1 - menu with columns to select which columns will be exported. Only columns with CanPrint>='1' are listed. (In TG prior 9.0 was tested CanExport instead of CanPrint.)
2 - (new 6.7) menu with column and also with options for export to PDF
See Configuration menu for basic settings or Print menu for special settings.
new 12.1 <Cfg> string

PDFFormat

["pdf"] Saved to cookies, avoid it by <Cfg PrintLap='1'/>
Format to export. TreeGrid provides server code and converters only for "pdf" format. Other formats must be handled by some custom converter. Case insensitive.
It is also file extension to save the report by, always lowercase.
new 12.1 <Cfg> string

PDFName

["Export"] Saved to cookies, avoid it by <Cfg PrintLap='1'/>
File name to save the exported PDF by. It is without extension, extension is set by PDFFormat.
new 6.7 chg 12.0 <Cfg> int

PDFFitPage

[0] Saved to cookies, avoid it by <Cfg PrintLap='1'/>
It can be set also in Print to PDF menu (when ExportPDFCols = 2) and is sent to server along with the request.
The options are defined in Text.xml, by default are: 0 = Real size, 1 = Width, 2 = Height (since 9.0), 3 = Single page.
Since 9.0 it is used by TreeGrid to calculate DPI and page size and apply page breaks.
Since 12.0 this attribute is used not only for PDF export, but also for normal printing to printer if set PrintZoomFit.
new 6.7 chg 9.0 <Cfg> int

PDFText

[1] Saved to cookies, avoid it by <Cfg PrintLap='1'/>
It can be set also in Print to PDF menu (when ExportPDFCols = 2) and is sent to server along with the request. It is not used by TreeGrid.
Since 9.0 it is hidden in menu by default, to show it set <Lang><Text PDFText='the text'/></Lang>
The options are defined in Text.xml, by default are: 0 = Image only, 1 = Selectable text, 2 = Selectable text with embedded fonts
new 6.7 deleted 9.0 <Cfg> int

PDFPageSize

[8] Saved to cookies, to not load it, set PrintLap='1'
Replaced by PrintPageSize.
new 6.7 deleted 9.0 <Cfg> int

PDFPageOrientation

[0] Saved to cookies, to not load it, set PrintLap='1'
Replaced by PrintPageOrientation.

Client side API

new 6.7 <Actions>

ExportPDF

Attached to event OnClickButtonExportPDF
Creates a request for report in PDF and sends it to server.
new 6.0 upd 7.0 API event bool

OnExportStart

(TGrid grid, bool pdf)
Called before the export report is generated.
(since 7.0) pdf is true for export to PDF.
Return true to cancel export.
new 12.1 API event bool

OnExportInit

(TGrid grid, string[Name] Cols, string[id] Rows, object source)
Called after the options are chosen by a user in menu and before the export is generated.
Cols is array of all columns to export, by column name. If the column is not listed, it is not exported.
Rows is array of rows to export, by row id. If the row is not listed, it is exported according to its CanExport value.
It is possible to modify these arrays.
Other settings like ExportFormat or ExportType are already read from configuration and can be modified in the grid attributes.
source is data source used, for PDF export it is grid.Source.ExportPDF.
Can be used for custom export or export to different formats.
Return true to cancel export.
chg 12.1 API event object

OnExport

(TGrid grid, object data, int type)
Called after the export or configuration is created and before it is saved to disk or sent to server.
data is the created export or configuration. It can be string or (since 12.1) Blob object.
(since 12.1) type is data type: 0 export configuration, 1 export pdf configuration, 2 direct data to save, 3 direct data to send to server.
Return true to suppress the export.
Or return new or updated data to send.
new 12.1 API method void

SaveExport

(string data, object source = null)
Saves exported data to file (source = null) or sends it to server to source like grid.Source.Export or grid.Source.ExportPDF.
chg 12.1 API method void

SendExport

(string data, string url, string name)
Sends the data to server as export or configuration.
Since 12.1 is does not call OnExport.

Server side API

API to generate the HTML for the HTML to PDF tool.

new 6.7 upd 14.1 global func. TGrid

PrintTreeGrid

(object Source, string tag = "", object param = null, object Page)
Creates and renders new grid by API according to settings in Source.
It renders inactive grid for printing purposes, especially when printing to PDF.
Use it only with GridE.js static script and not with GridED.js on demand script, because with GridED.js script is asynchronous.
It prints the grid synchronously, without scrollbars, loads also all pages and child pages in server paging, so it can be very slow for long grids.
For long grids and routines that use IE for exporting to PDF it can be useful to disable slow script message in IE by:
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Styles\MaxScriptStatements = 0xFFFFFFFF
Its attributes and other behavior is similar to TreeGrid method.
Source can be:
a) string with <treegrid> or <bdo> tag with all settings like it is included directly to HTML
Example: TreeGrid("<treegrid Data_Url='Grid2.xml'></treegrid>","Main");
b) string with XML to create the grid from. The grid will have only Data_Data source defined.
Example: TreeGrid("<Grid><Cols><C Name='A'/></Cols><Body><B><I A='xxx'/></B></Body></Grid>","Main");
c) object with parsed <treegrid> / <bdo> tag.
All multilevel attributes (data sources) containing '_' must be set as nested objects, split by the '_',
for example Data_Param_Test is accessed as Source.Data.Param.Test and set as {Data:{Param:{Test:'val'}}}
Eample: PrintTreeGrid({Layout:{Url:"Grid2Def.xml"},Data:{Url:"Grid2.xml"}},"Main");
tag is the main div tag to render grid into. The tag can be an id of the tag or the HTMLElement itself. The htm tag must exist in time of calling the function.
If the parameter is missing, the id of the tag must be set in input XML by attribute <Cfg Tag/>. See <treegrid> tag description.
param are (since 14.1) the attributes that will be set to the created grid.
It is useful to pass here some link to the parent object that creates TreeGrid, e.g. this.Grid = TreeGrid({Data:{Url:"Test.xml"}},"Main",{id:"TestGrid",Component:this});
The param can contain id attribute or the param can be a string to be used as the id attribute.
The id is the unique id of the grid, used to identify it, to access the grid object globally by Grids[id].
The id is also used in saving configuration to the cookies if not set CfgId attribute.
If the id is not set in/by param, the id of the grid can be set in the Source or input XML by attribute <Cfg id/> or it is autogenerated.
Page since 14.0 are parameters for printing every page:
Width - width of the printed page in millimeters, including margin.
Height - height of the printed page in millimeters, including margin.
MarginWidth - width of the left+right page margin in millimeters.
MarginHeight - height of the top+bottom page margin in millimeters.
Dpi - dpi (scale) ratio, 96 is 1 (default), higher value decreases page scale and vice versa.
FitPage - How to fit content to page 0 - none, 1 - to width, 2 - to height, 3 - single page. Set only for server paging, when client side cannot calculate dpi for fit
Header - html displayed in top margin on every page.
HeaderLink - url assigned to Header.
HeaderBackground - background color for the Header.
Footer - html displayed in bottom margin on every page. By default it displays white background to hide the default Chrome footer. In case of problems set Footer="" to ignore it at all.
FooterBackground - background color for the Footer.
FooterLink - url assigned to Footer.
Update - value of ChangesUpdate, default value is 0 for printing to PDF.
The function returns created TGrid object.
Since 14.1 if used GridED.js on demand script instead of GridE.js static script, the function downloads the GridE.js asynchronously and always returns before the TreeGrid is initialized and loaded - the returned grid object has set only its Source attribute.
It returns null for fatal error. It fails if the Source is null or cannot be used as one of the three options.
The Source is accessible by API by grid.Source attribute.
It calls all loading events like OnLoaded or OnReady.
(Since 7.0) It calls also OnRenderStart event, when all data are loaded, even for server paging and OnRenderFinish when the grid is fully rendered (even for paging).
API event string

OnGetHtmlValue

(TGrid grid, TRow row, string col, type val)
Called to get formatted cell value to display. val is unformatted cell value.
Returns formatted value. If returned value is not null, it is used instead of internal formatting by Format or Enum attributes.
Return null to use default formatting behavior.

Data sent from client to server

To server is sent just actual grid configuration - sorting, grouping, filters, search and column width, positions and visibility.
In "custom" parameter "ExportFormat" is sent "pdf" (to distinguish it from other export formats when sharing the export url)
In "custom" parameters PrintPageSize, PrintPageOrientation, PrintDPI, PrintMarginWidth, PrintMarginHeight, PDFFitPage and PDFText are sent chosen PDF options, see them in Page size and Printing options.
Since 14.0 in "custom" parameters PrintPageWidth and PrintPageHeight is sent the page size in millimeters, including margins.

It is possible to upload also other data from client like changes, set Export_Type="Settings,Changes".
The configuration is sent as standard TreeGrid XML in Data attribute.

XML structure of request for PDF export

Used as request sent to data source ExportPDF to get the exported grid when set server side export (ExportPDF_Type="Settings").
It contains session identification and grid configuration to sort, group, filter and search exported data on server.
It contains also columns settings - width, position and visibility.

<Grid>
<IO ... attributes with request settings ... /> (Session attribute)
<Cfg ... attributes with grid settings read from cookies ... />
(Sort, Group, ReSort, ReCalc, TimeZone attributes)
(SearchAction, SearchExpression, SearchType, SearchMethod, SearchDefs, SearchCols attributes)
(Focused, FocusedCol, FocusedPos attributes)
(PrintPageBreaks, PrintRows, PrintExpanded, PrintFiltered)
<Filter> (list of filters)
<I ... row and cell attributes ... /> (id attribute, cell values and cell Filter attributes)
... More tags <I> if more filters are in grid ...
</Filter>

<LeftCols>
<C Name='column name' Width='...' Visible='0/1' />
... more tags <C> for other columns ...
</LeftCols>
<Cols>
<C Name='column name' Width='...' Visible='0/1' />
... more tags <C> for other columns ...
</Cols>
<RightCols>
<C Name='column name' Width='...' Visible='0/1' />
... more tags <C> for other columns ...
</RightCols>

</Grid>