This is the default implementation of a DataModel used by the Grid. It works
with multi-dimensional array based data. Using the event system in the base class
YAHOO.ext.grid.AbstractDataModel, all updates to this DataModel are automatically
reflected in the user interface.
Usage:
var myData = [
["MSFT","Microsoft Corporation", "314,571.156", "32,187.000", "55000"],
["ORCL", "Oracle Corporation", "62,615.266", "9,519.000", "40650"]
];
var dataModel = new YAHOO.ext.grid.DefaultDataModel(myData);
|
addListener : Object |
AbstractDataModel |
Inherited from Observable |
|
delayedListener : Object |
AbstractDataModel |
Inherited from Observable |
|
fireEvent : Object |
AbstractDataModel |
Inherited from Observable |
|
on : Object |
AbstractDataModel |
Inherited from Observable |
|
onCellUpdated : YAHOO.util.CustomEvent |
AbstractDataModel |
Deprecated. Fires when a cell is updated - fireDirect sig: (this, rowIndex, columnIndex) |
|
onRowsDeleted : YAHOO.util.CustomEvent |
AbstractDataModel |
Deprecated. Fires when rows are deleted - fireDirect sig: (this, firstRowIndex, lastRowIndex) |
|
onRowsInserted : YAHOO.util.CustomEvent |
AbstractDataModel |
Deprecated. Fires when a rows are inserted - fireDirect sig: (this, firstRowIndex, lastRowIndex) |
|
onRowsSorted : YAHOO.util.CustomEvent |
AbstractDataModel |
Deprecated. Fires when a sort has reordered the rows - fireDirect sig: (this, sortColumnIndex,
sortDirection = 'ASC'... |
|
onRowsUpdated : YAHOO.util.CustomEvent |
AbstractDataModel |
Deprecated. Fires when a rows are updated - fireDirect sig: (this, firstRowIndex, lastRowIndex) |
|
onTableDataChanged : YAHOO.util.CustomEvent |
AbstractDataModel |
Deprecated. Fires when all data needs to be revalidated - fireDirect sig: (thisd) |
|
removeListener : Object |
AbstractDataModel |
Inherited from Observable |
|
DefaultDataModel() |
DefaultDataModel |
|
|
addRow(Array cellValues ) : Number |
DefaultDataModel |
Adds a row to the dataset. |
|
applySort() : void |
DefaultDataModel |
Applies the last used sort to the current data. |
|
each() : void |
DefaultDataModel |
Calls passed function with each rows data - if the function returns false it stops. |
|
filter(Object query ) : Number |
DefaultDataModel |
Filter the DataModel rows by the query defined in spec, see query for more details
on the query spec. |
|
fireCellUpdated() : void |
AbstractDataModel |
Notifies listeners that the value of the cell at [row, col] has been updated |
|
fireRowsDeleted() : void |
AbstractDataModel |
Notifies listeners that rows in the range [firstRow, lastRow], inclusive, have been deleted |
|
fireRowsInserted() : void |
AbstractDataModel |
Notifies listeners that rows in the range [firstRow, lastRow], inclusive, have been inserted |
|
fireRowsSorted() : void |
AbstractDataModel |
Notifies listeners that rows have been sorted and any indexes may be invalid |
|
fireRowsUpdated() : void |
AbstractDataModel |
Notifies listeners that rows in the range [firstRow, lastRow], inclusive, have been updated |
|
fireTableDataChanged() : void |
AbstractDataModel |
Notifies listeners that all data for the grid may have changed - use as a last resort. This
also wipes out all selec... |
|
getRow() : Array |
DefaultDataModel |
Returns the column data for the specified row. |
|
getRowCount() : Number |
DefaultDataModel |
Returns the number of rows in the dataset |
|
getRowId() : Number |
DefaultDataModel |
Returns the ID of the specified row. By default it return the value of the first column.
Override to provide more ad... |
|
getRows(Array indexes ) : Array |
DefaultDataModel |
Returns the column data for the specified rows as a
multi-dimensional array: rows[3][0] would give you the value of ... |
|
getSortState() : Object |
AbstractDataModel |
Interface method to supply the view with info regarding the Grid's current sort state - if overridden,
this should re... |
|
getTotalRowCount() : void |
AbstractDataModel |
Empty interface method - Classes which extend AbstractDataModel should implement this method to support virtual row c... |
|
getValueAt(Number rowIndex , Number colIndex ) : Object |
DefaultDataModel |
Returns the value at the specified data position |
|
insertRow(Number index , Array cellValues ) : Number |
DefaultDataModel |
Inserts a row a the specified location in the dataset. |
|
query(Object spec , Boolean returnUnmatched ) : Array |
DefaultDataModel |
Query the DataModel rows by the filters defined in spec, for example...
// column 1 starts with Jack, column 2 filte... |
|
removeRow(Number index ) : void |
DefaultDataModel |
Remove a row. |
|
setValueAt(Object value , Number rowIndex , Number colIndex ) : void |
DefaultDataModel |
Sets the specified value at the specified data position |
|
sort(Function/Object sortInfo , Number columnIndex , String direction ) : void |
DefaultDataModel |
Sorts the data by the specified column - Uses the sortType specified for the column in the passed columnModel. |
This class has no public events.
addListener
public Object addListener
Inherited from Observable
delayedListener
public Object delayedListener
Inherited from Observable
fireEvent
public Object fireEvent
Inherited from Observable
on
public Object on
Inherited from Observable
onCellUpdated
public YAHOO.util.CustomEvent onCellUpdated
Deprecated. Fires when a cell is updated - fireDirect sig: (this, rowIndex, columnIndex)
onRowsDeleted
public YAHOO.util.CustomEvent onRowsDeleted
Deprecated. Fires when rows are deleted - fireDirect sig: (this, firstRowIndex, lastRowIndex)
onRowsInserted
public YAHOO.util.CustomEvent onRowsInserted
Deprecated. Fires when a rows are inserted - fireDirect sig: (this, firstRowIndex, lastRowIndex)
onRowsSorted
public YAHOO.util.CustomEvent onRowsSorted
Deprecated. Fires when a sort has reordered the rows - fireDirect sig: (this, sortColumnIndex,
sortDirection = 'ASC' or 'DESC')
onRowsUpdated
public YAHOO.util.CustomEvent onRowsUpdated
Deprecated. Fires when a rows are updated - fireDirect sig: (this, firstRowIndex, lastRowIndex)
onTableDataChanged
public YAHOO.util.CustomEvent onTableDataChanged
Deprecated. Fires when all data needs to be revalidated - fireDirect sig: (thisd)
removeListener
public Object removeListener
Inherited from Observable
addRow
public function addRow(Array cellValues
)
Adds a row to the dataset.
This method is defined by DefaultDataModel.
applySort
public function applySort()
Applies the last used sort to the current data.
This method is defined by DefaultDataModel.
each
public function each()
Calls passed function with each rows data - if the function returns false it stops.
This method is defined by DefaultDataModel.
filter
public function filter(Object query
)
Filter the DataModel rows by the query defined in spec, see
query for more details
on the query spec.
This method is defined by DefaultDataModel.
fireCellUpdated
public function fireCellUpdated()
Notifies listeners that the value of the cell at [row, col] has been updated
fireRowsDeleted
public function fireRowsDeleted()
Notifies listeners that rows in the range [firstRow, lastRow], inclusive, have been deleted
fireRowsInserted
public function fireRowsInserted()
Notifies listeners that rows in the range [firstRow, lastRow], inclusive, have been inserted
fireRowsSorted
public function fireRowsSorted()
Notifies listeners that rows have been sorted and any indexes may be invalid
fireRowsUpdated
public function fireRowsUpdated()
Notifies listeners that rows in the range [firstRow, lastRow], inclusive, have been updated
fireTableDataChanged
public function fireTableDataChanged()
Notifies listeners that all data for the grid may have changed - use as a last resort. This
also wipes out all selections a user might have made.
getRow
public function getRow()
Returns the column data for the specified row.
This method is defined by DefaultDataModel.
getRowCount
public function getRowCount()
Returns the number of rows in the dataset
This method is defined by DefaultDataModel.
getRowId
public function getRowId()
Returns the ID of the specified row. By default it return the value of the first column.
Override to provide more advanced ID handling.
This method is defined by DefaultDataModel.
getRows
public function getRows(Array indexes
)
Returns the column data for the specified rows as a
multi-dimensional array: rows[3][0] would give you the value of row 4, column 0.
Parameters:
indexes
: ArrayThe row indexes to fetch
Returns:
This method is defined by DefaultDataModel.
getSortState
public function getSortState()
Interface method to supply the view with info regarding the Grid's current sort state - if overridden,
this should return an object like this {column: this.sortColumn, direction: this.sortDir}.
getTotalRowCount
public function getTotalRowCount()
Empty interface method - Classes which extend AbstractDataModel should implement this method to support virtual row counts.
getValueAt
public function getValueAt(Number rowIndex
, Number colIndex
)
Returns the value at the specified data position
Parameters:
rowIndex
: NumbercolIndex
: Number
Returns:
This method is defined by DefaultDataModel.
insertRow
public function insertRow(Number index
, Array cellValues
)
Inserts a row a the specified location in the dataset.
This method is defined by DefaultDataModel.
query
public function query(Object spec
, Boolean returnUnmatched
)
Query the DataModel rows by the filters defined in spec, for example...
// column 1 starts with Jack, column 2 filtered by myFcn, column 3 equals 'Fred'
dataModel.filter({1: /^Jack.+/i}, 2: myFcn, 3: 'Fred'});
Parameters:
spec
: ObjectThe spec is generally an object literal consisting of column index and filter type. The filter type can be a string/number (exact match), a regular expression to test using String.search() or a function to call. If it's a function, it will be called with the value for the specified column and an array of the all column values for that row: yourFcn(value, columnData). If it returns anything other than true, the row is not a match. If you have modified Object.prototype this method may fail.
returnUnmatched
: BooleanTrue to return rows which don't match the query instead of rows that do match
Returns:
This method is defined by DefaultDataModel.
removeRow
public function removeRow(Number index
)
This method is defined by DefaultDataModel.
setValueAt
public function setValueAt(Object value
, Number rowIndex
, Number colIndex
)
Sets the specified value at the specified data position
Parameters:
value
: ObjectThe new value
rowIndex
: NumbercolIndex
: Number
Returns:
This method is defined by DefaultDataModel.
sort
public function sort(Function/Object sortInfo
, Number columnIndex
, String direction
)
Sorts the data by the specified column - Uses the sortType specified for the column in the passed columnModel.
Parameters:
sortInfo
: Function/ObjectA sort comparison function or null to use the default or A object that has a method getSortType(index) that returns a function like a grid column model.
columnIndex
: NumberThe column index to sort by
direction
: StringThe direction of the sort ('DESC' or 'ASC')
Returns:
This method is defined by DefaultDataModel.