dwr.util.addRows(id, array, cellfuncs, [options]);
Adds rows to a table element specified by id. It takes it's data from an array and creates a row in the table for each entry in the array. A column is created for each function in the cellfuncs array. The cells are created by passing each array entry to each 'cellfunc' in turn. For worked examples see the tables documentation.
As of DWR 1.1, addRows() also works with objects. If you pass in an object in place of an array we will create cells by passing object values to the cell functions.
You could write some pseudo-code that looks something like this:
for each member in array for each function in cellfuncs create cell from cellfunc(array[i])
By default DWR protects against XSS in dwr.util.addRows by performing output escaping. The optional options object parameter allows output escaping to be disabled. Please see the escapeHtml page for more information.
- id: The id of the table element (preferably a tbody element)
- array: Array (or object from DWR 1.1) containing one entry for each row in the updated table
- cellfuncs: An array of functions (one per column) for extracting cell data from the passed row data
- options: An object containing various options (see below)
From DWR 1.1, the options available are:
- rowCreator: a function that will create a row for you (e.g. you wish to add css to the tr). The default returns document.createElement("tr")
- cellCreator: a function to create a cell, (e.g. to use a th in place of a td). The default returns document.createElement("td")
- escapeHtml: Set to false to prevent DWR from performing output escaping. See the full documentation on escapeHtml for more information.