Creating a Rico LiveGrid

Rico LiveGrid displays data in a scrolling table, with the data buffered in a 2-dimensional JavaScript array. As the user scrolls vertically through the grid, data is dynamically copied from the array onto the grid. The buffer can can be loaded from:

  1. an HTML table
  2. an XML file
  3. a SQL database query

Usage Model 1: Loading data from an HTML table

Usage Model 2: Loading data from an XML file

Usage Model 3: Loading data from an SQL database query

The descriptions below apply directly to the ASP and PHP implementations of LiveGrid. The concepts are the same in .net, but the implementation is quite different (examine ex2simple.aspx to see how this gets implemented in .net).

Debugging

Rico 2.0 includes the ability route time-stamped debug messages to a message log. The log may be an html textarea or the browser's javascript console.

Notes

Reference

Constructor


  var grid = new Rico.LiveGrid (table_id, rico_buffer, grid_options);

Options

Grid Size

visibleRows (rows in .net)
How many rows of the grid are made visible? A positive integer specifies that the grid should always contain exactly that many rows. Negative values have the following meanings:
minPageRows
Minimum # of visible rows. Used only when visibleRows < 0. (default: 2 - after Rico 2b3, 1 - up to Rico 2b3)
maxPageRows
Maximum # of visible rows. Used only when visibleRows < 0. (default: 50)

Grid Data

offset
First row of data to be displayed (default: 0)
prefetchBuffer
Load the buffer (and therefore the grid) on page load? (default: true)
sortCol
Name or index of column for initial sort
sortDir
Direction of initial sort
possible values: 'ASC', 'DESC'
getQueryParms
If true, check the web page's query string for filter parameters and apply any filter that is found. Filter parameters must be of the form "f[x]=" where x is the column index. (default: false)

Header Configuration

headingSort
A string that defines how headings are displayed to facilitate sorting.
hdrIconsFirst
Put sort and filter icons before or after header text (default: true)
panels
An array of strings that can serve as secondary headings. In LiveGrid Forms, they also serve as the headings for the tabbed panels on the input form.
PanelNamesOnTabHdr
Set to 'true' for the strings in panels[] to be used as secondary headings. In LiveGrid Forms, it may be set to 'false' so that panels[] is only used on the input form.

Images

resizeBackground
Image to use for column resize handle. (default: 'resize.gif')
sortAscendImg
Image to use to indicate that the column is sorted in ascending order. (default: 'sort_asc.gif')
sortDescendImg
Image to use to indicate that the column is sorted in descending order. (default: 'sort_desc.gif')
filterImg
Image used to indicate an active filter on a column. (default: 'filtercol.gif')

Cookie options

saveColumnInfo
Specifies which details to save in the grid's cookie. Only one cookie is used for each grid. Note that the width setting includes the hide/show status of the column. (default: {width:true, filter:false, sort:false})
cookiePrefix
A string that is prepended to the cookie name. (default: 'RicoGrid.')
cookieDays
Number of days before the cookie expires. If you don't specify it, then the cookie is only maintained for the current session. (default: null)
cookiePath
Sets the top level directory from which the grid cookie can be read. If you don't specify it, it becomes the path of the page that sets the cookie. (default: null)
cookieDomain
Tells the browser to which domain the cookie should be sent. If you don't specify it, it becomes the domain of the page that sets the cookie. (default: null)

Highlighting and selection

highlightSection
which section of the table is highlighted
highlightMethod
Method used to highlight cells & rows. Possible values:
highlightClass
When highlighting by class, this is the class name used (default: 'ricoLG_selection')

Export and print

maxPrint
The maximum number of rows that the user is allowed to Print/Export. Set to 0 to disable print/export. (default: 1000)

Event-handling

Event handlers cannot be passed in options to the constructor, but may be set after the LiveGrid has been constructed.

sortHandler
(default: Rico.LiveGridMethods.sortHandler -- bound)
filterHandler
(default: Rico.LiveGridMethods.filterHandler -- bound)
onRefreshComplete
(default: Rico.LiveGridMethods.bookmarkHandler -- bound)
rowOverHandler
(default: Rico.LiveGridMethods.rowMouseOver -- bound as event listener)
mouseDownHandler
(default: Rico.LiveGridMethods.selectMouseDown -- bound as event listener)
mouseOverHandler
(default: Rico.LiveGridMethods.selectMouseOver -- bound as event listener)
mouseUpHandler
(default: Rico.LiveGridMethods.selectMouseUp -- bound as event listener)
onscroll
called whenever the grid is scrolled vertically. (default: null)
onscrollidle
called 1.2 seconds after the grid is scrolled vertically. (default: null)

Per-column configuration

Options for each individual column are contained in the columnSpecs option. columnSpecs is an array with an entry for each column. Each column entry can either be:

Here is an example that contains specifications for columns 0, 1, and 3:

columnSpecs : [{canSort:false, noResize:true, ClassName:'alignright'},
               {ClassName:'aligncenter'},
               ,
               {visible:false}]
Hdg
An alternate way of specifying the heading text for a column. Only used by LiveGrid if the grid id refers to a <div> instead of an html table.
canSort
Column can be sorted. (default: grid.options.canSortDefault)
canFilter
Column can be filtered. (default: grid.options.canFilterDefault)
canHide
Column can be hidden/unhidden. (default: grid.options.canHideDefault)
visible
Column is initially unhidden. If grid.options.saveColumnInfo.width is true and there is a value in the cookie for this column, the cookie value will take precedence. (default: true)
width
Initial width for column. If grid.options.saveColumnInfo.width is true and there is a value in the cookie for this column, the cookie value will take precedence. (default: grid.options.defaultWidth)
noResize
Allow column to be resized? (default grid.options.allowColResize )
ClassName
Set this to 'alignright' or 'aligncenter' as needed - see example. Note that this does not align the header - use a align="right" on the <th> line to accomplish the header alignment. (default: table_id + '_col' + column_index)
format
possible values: dollar, euro, percent, qty, default
type
possible values: text, showTags, number, datetime, date, control, raw (default)
control
If type=control, then this is the object used to format data in the column.

Number formatting:

multiplier
The value is multiplied by this number before it is displayed. (default: 1)
decPlaces
Number of places to the right of the decimal point. (default: 0)
decPoint
Decimal point symbol. (default: '.' but overridden in the translation files)
thouSep
Symbol for thousands separator. (default: ',' but overridden in the translation files)
negSign
Specifies how negative numbers should be displayed. Possible values:
prefix
A string added to the beginning of the number. Typically a currency symbol.
suffix
A string added to the end of a number. For example, a "%" symbol.

Date formatting:

dateFmt
A string specifying how the date or datetime should be displayed. Default is "translateDate", which means that the dateFmt and timeFmt strings in the RicoTranslate object are used (this defaults to "mm/dd/yyyy" for dates and "mm/dd/yy hh:mm:ss a/pm" for datetimes, but is overridden by the various language translation files). If dateFmt="localeDate", then the value is formatted using javascript's built-in toLocaleDateString() function. If dateFmt="localeDateTime", then the value is formatted using javascript's built-in toLocaleString() function. The dateFmt string may contain the following special character sequences:
// display first column as "month year"
columnSpecs : [{type:date, dateFmt:'mmm yyyy'}]
prefix
A string added to the beginning of the date.
suffix
A string added to the end of a date. For example, you could use this to include a time zone:
// indicate that times are GMT/UTC
columnSpecs : [{type:datetime, suffix:' UTC'}]