TreeGrid v6.0

Print grid

TreeGrid documentation index

 

User can print grid by clicking to Print button on toolbar.

TreeGrid opens new window and renders here the grid again and calls standard window.print method to show printing dialog and print the grid. The printing process itself cannot be controlled by JavaScript at all.

 

The grid rendered for printing does not show scrollbars, but displays the whole grid. It does not show right side pager. All other parts visibility can be controlled by CanPrint attributes.

 

Because TreeGrid uses background images, a user must have permitted “Printing background images” in his browser to successfully print the grid.

 

<I>                   int        CanPrint              [0/1/2]                                                                                                  new 6.0       .

If the row will be printed.

0 - never, 1 - once, 2 - on every page (only for fixed and space rows).

By default Toolbar has 0, Header has 2 and all other rows have 1.

 

<C>                 bool      CanPrint              [0/1]                                                                                                   new 6.0       .

If the column will be printed.

By default Panel has 0 and other columns 1.

 

<Cfg>              bool      PrintExpanded          [0]        Saved to cookies, to not load it, set PrintLap=’1’  renamed 6.0;upd 6.7.

If prints all rows expanded.

If set to 0, only actually expanded rows prints their children.

Since 6.7 it can be changed via print menu and is saved to cookies.

 

<Cfg>              bool      PrintFiltered    [0]        Saved to cookies, to not load it, set PrintLap=’1’                     new 6.7.

If prints all rows, including the hidden.

It can be changed via print menu and is saved to cookies.

 

<Cfg>              bool      PrintPageBreaks     [0]        Saved to cookies, to not load it, set PrintLap=’1’  renamed 6.0;upd 6.7.

Prints page break after every PrintRows variable rows.

For every page it prints new table with all fixed and space rows that have CanPrint=’2’

Since 6.7 it can be changed via print menu and is saved to cookies.

 

<Cfg>              int        PrintCols            [0]                                                                                           new 6.0;upd 6.7.

If and which menu will be shown before printing.

0 – no menu

1 – menu with columns to select which columns will be printed. Only columns with CanPrint=’1’ are listed.

2(new 6.7) menu with column and also with printing options

 

<Cfg>              bool      PrintCheckboxes    [0]                                                                                           new 6.7       .

For 1 it prints all checkboxes and radio buttons as standard HTML checkbox and radio button inputs instead of style images.

Useful when expected printing without background images.

 

<Cfg>              int        PrintRows         [50]      Saved to cookies, to not load it, set PrintLap=’1’                     upd 6.7.

For how many rows will be displayed and updated progress bar. Displaying progress bar suppresses also message about slow script. 0 never shows progress bar.

Too small value can slow down the printing.

It is used also as page length for PrintPageBreaks.

Since 6.7 it can be changed via print menu and is saved to cookies.

 

<Cfg>              string    PrintPrefix                                                                                                                              .

HTML code added in front of TreeGrid when printing

 

<Cfg>              string    PrintPostfix                                                                                                                           .

HTML code added behind TreeGrid when printing

 

<Cfg>              string    PrintCSS                                                                                                                                  .

Url of CSS style sheet for printing used instead of default CSS style sheet

 

<Cfg>              string    PrintWindowProp                                                                                                             .

Properties of printing window (the third attribute to window.open)

 

API event         bool      OnPrintStart    (TGrid grid)                                                                                        new 6.0       .

Called before the print report is generated.

Return true to cancel printing.

 

API event         string    OnPrint    (TGrid grid, Window window, string report)                                                     chg 6.0       .

Called after the print report has been generated, but before it was written to the print window and printed

Return true to cancel printing or own print.

Or return new or updated report to print.

window is new window created for printing and should be closed when OnPrint returns true.

report is the generated grid HTML that will be printed.

 

API event         bool      OnPrintFinish            (TGrid grid, Window window)                                                              .

Called after print report is written to the window and before the printing dialog is displayed.

window is browser’s window that contains the report.

You can also use this event to get back changes you done in OnPrintStart event, if any.

Return true to suppress default action. You can call here window.print() in this event and do some action after, for example to close the window.

 

API method     string    GetPrintable    (function func)                                                                                     chg 6.0       .

Generates print report for the grid.

If func is not set, it generates the report synchronously without displaying message and returns the generated report.

If func is set, it generates the report asynchronously, shows and updates progress message and after finish calls func (report).

 

<Actions>                    Print                       Attached to event OnClickButtonPrint                                                             .

Shows printable version or grid and displays dialog for printing

 

global func.     TGrid    PrintTreeGrid            (object Source, string tag = “”, string id = “”)                              new 6.7       .

Creates and renders new grid by API according to settings in Source.

It renders inactive grid for printing purposes, especially when printing to PDF.

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.

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.

id is the unique id of the grid, used to identify it, especially in saving configuration to the cookies.

If the parameter is missing, the id of the grid can be set in input XML by attribute <Cfg id/>

The function returns created TGrid object.

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.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

.