File: aTable.js

Fields

  • columns : ColumnCollection - The collection of Column models representing the table columns

  • rows : RowCollection - The collection of Row models containing the table's data

Functions

close ()

Remove this aTable from the DOM, and unbind all events

filter ( column, filterStr, caseSensitive )

Filter the table by displaying only rows which contain filterStr in the contents of column
Parameters
  • column : String
    name of the column to filter on
  • filterStr : String
    check specified column for existence of this string
  • caseSensitive : boolean (Optional)
    use caseSensitive filtering

getColumnByPosition ( position )

Returns the Column given its position in the set of visible columns
Parameters
  • position : int
    index of the column, ignoring any invisible columns
Returns
  • Column - the column model at position, or null if the position is invalid

hideColumn ( name )

Make a column invisible, causing it to not render
Parameters
  • name : String
    unique column name

initialize ( options )

Parameters
  • options : Object
    hash of parameters
    • options.columns : Object[]
      array of objects defining the table columns. Each object has the following properties:
      • options.columns.name : String
        name of the column. This value must be unique.
      • options.columns.label : String (Optional)
        displayed name of the column. Unlike name, the label need not be unique.
      • options.columns.width : int (Optional)
        explicit width of the column in pixels
      • options.columns.resizable : boolean (Optional)
        set whether the column is resizable. This value takes precedence over options.resizableColumns.
      • options.columns.sortable : boolean (Optional)
        set whether the table can be sorted on this column. This value takes precedence over options.sortableColumns.
      • options.columns.visible : boolean (Optional)
        set whether the column is visible
      • options.columns.cellClasses : String (Optional)
        space-separated list of CSS classes to apply to the content of all of this column's cells
    • options.dataFunction : String|Function
      The dataFunction parameter can be one of two values:
    • {String} the id of a <script> element containing a function which has the same name as the script id. The function should call self.postMessage({data: rows, append: append}); where rows is a 2-dimensional array of table values. If append is true, rows will be added to the table. If false, the rows will completely replace the existing table.
    • {Function} a function responsible for generating the table's dataset. It should have one parameter, atable, and call atable.receivedData(rows, append); to deliver data to the table

    • *Note that both methods of returning table data may do so many times (e.g. a loop that continuously uses ajax polling to get new data from the server).
  • options.el : String
    CSS selector of the DOM element in which to insert the rendered table
  • options.height : int
    max height of the table in pixels
  • options.resizableColumns : boolean (Optional)
    set whether table columns are resizable
  • options.movableColumns : boolean (Optional)
    set whether table columns are movable
  • options.sortableColumns : boolean (Optional)
    set whether clicking on column headers sorts the table
  • options.cellClasses : String (Optional)
    space-separated list of CSS classes to apply to the content of all the cells in the table
  • options.sortColumn : String (Optional)
    name of the column by which to sort the table
  • options.formatter : Function (Optional)
    function called on each cell value to provide arbitrary formatting/transformation. Takes the value, row index, column index, and column name as parameters and returns the formatted value.

  • moveColumn ( column, dest )

    Move a column to a different position, shifting all columns in between
    Parameters
    • column : String|int
      name or position of the column to be moved
    • dest : String|int
      name of the column currently in the desired position, or the position itself

    receivedData ( data, append )

    Update the row collection with new data from the data function
    Parameters
    • data : Array[]
      matrix of row data returned by the data function
    • append : boolean (Optional)
      if true, append new rows to the dataset, otherwise replace the dataset

    renameColumn ( name, newLabel )

    Change the label (display name) of a column
    Parameters
    • name : String
      unique name of the column
    • newLabel : String
      new label for the column

    render ( callback )

    Generates the ATable and adds it to the DOM
    Parameters
    • callback : function (Optional)
      function to call when the ATable is rendered

    resizeColumn ( column, newWidth )

    Resize a column. Causes the table to re-render.
    Parameters
    • column : String
      name of the column to resize
    • newWidth : int
      new column width in pixels

    showColumn ( name )

    Make a column visible, causing it to render
    Parameters
    • name : String
      unique column name

    sort ( column, descending )

    Sort the table rows by the specified column and order
    Parameters
    • column : String
      name of the column to sort on
    • descending : boolean (Optional)
      sort in descending order