Translations of this page:

The edit_table draws a table that is editable. The storage of the edited date is not done by the table itself. You as developer using the table, have to store the data yourself in a database or wherever you like store the data. the editable table provides methods to read the changed data.

The edit_table is a subclass of datatable.

edit_table(target, cols, colTitles, colWidths) [Constructor]

instantiates the edit_table

  • target: a DOM-Element, or the id of a DOM-Element, in which the table should be drawn.
  • cols: numeric Array of the columns to show, this array defines the column order.
  • colTitles: optional, Hashtable, Key: column name, Value: their caption.
  • colWidths: optional, Hashtable, Key: column name, Value: witch in pixels.

drawTable(data, pos, sortedCol, sortDir)

Passes the data to show to the table. The table redraws itself after this call. principally works like drawTable in the datatable, unsaved changes will be lost.

  • data: a numeric array of the records to show, the records itself should be hashtables, key: the columnname, value: the value
  • pos: optional, the absolute position of the first record in data, this is especially used if the table is used by a chachedtable
  • sortedCol: optional, one of the shown columns. this does NOT sort the given data, it does just indicate that the data is sorted by this column. A little array will be shown in the this column's header.
  • sortDir: optional, the sort diraction of the sortedCol (“ASC” oder “DESC”), to draw the right arrow.

setEditor(colName, editor)

Sets a special editor for the cell-values of a specified column. An editor must be a subclass of input (in modules/tools/input.js). The table uses the methods setValue and getValue of the given editors and the on app defined methods “setContainer”. If no editor is set for a particular column a “normal” text-input is used as editor component.

To achieve that a column will get “read-only” set its editor to null

Examples:

table.setEditor('id', null);                           // makes the id-column read-only
table.setEditor('income', new number_input(null));     // Sets the income-editor to "numbers-only" textinput
table.setEditor('birthday', new dateinput(null));      // Sets the editor to a dateinput, a module to enter dates

var divisions = {'R&D':'Development', 'prod':'Production', 'sales':'Sales', 'purchase':'Purchasing'};
table.setEditor('department', new selector(null, divisions ));     // to use a selector for division.

undo()

Revokes the users changes.

newEntry()

Adds a new row at the end of the table an sets the courser into it.

isEdited()

returns whether anything has been edited or not

getUpdatedRows(idAsKey)

Returns a hashtable of all edited rows. As key, the value of the defined idCol is user (see setIdCol at datatable)

@param idAsKey boolean - OPTIONAL - If this argument is set to true, the method returns a numeric array of the edited rows.

If the idCol is not set a numeric array will be returned. The records itself are hashtables, key: columnname, value: the value

getInsertedRows()

returns a numeric array of the newly created rows. The records itself are hashtables, key: columnname, value: the value

getAllEditedRows()

Returns a numeric array of all edited rows and all inserted rows.

A shortcut for:

var updated = table.getUpdatedRows(false);  // als numeric Array
var inserted = table.getInsertedRows();
 
en/dev/edit_table.txt · Last modified: 10.12.2007 11:16 by kaegi
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki