Rendering the output

Rendering the output

Rendering the output -- What formats can I render the output?


The DataGrid offers the ability to build out your data in a grid format in an HTML table, which is the most common method due to the nature of PHP. However, the DataGrid offers many other ways of outputting the tabular data structure such as an Excel Spreadsheet or an XML document.

How do I change the formatter?

To use a different formatter other than the HTML Table, you can simply change the formatter by either defining the formatter in the Constructor method or by using the setFormatter method. The parameter for defining the formatter is specified by one of the formatter constants.

Currently Available Renderers

The following listed are the renderers that are available in the DataGrid package.

HTML Table (Default)

This renderer uses the PEAR::HTML_Table package to create an HTML table of the data.


This will allow you to render the datagrid as an XML document.

Excel Spreadsheet

This renderer uses the PEAR::Spreadsheet_Excel_Writer package to create an Excel Spreadsheet.


XUL is a language developed by the Mozilla Foundation for creating rich user-interfaces. One component of XUL is a DataGrid like structure. With this renderer you can easily add an XUL listbox to you XUL application.


This renderer uses the PEAR::Console_Table package and will allow you to create a console table very easily.


With the use of the Smarty renderer you can add a DataGrid to your Smarty template.


With this renderer you can convert the format of your data. With this option you can, for example, input an XML file into the datagrid, present it via HTML and then allow the end-user to download it via a CSV file. This can lead to countless ways for converting data formats.

© Copyright 2003-2023 The ultimate PHP Editor and PHP IDE site.