Object
|
+--YAHOO.ext.grid.AbstractDataModel
|
+--YAHOO.ext.grid.DefaultDataModel
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);
| Fields inherited from class YAHOO.ext.grid.AbstractDataModel |
onCellUpdated, onTableDataChanged, onRowsDeleted, onRowsInserted, onRowsUpdated, onRowsSorted, events, addListener, removeListener, fireEvent
|
| Constructor Summary | |
YAHOO.ext.grid.DefaultDataModel
(data)
|
|
| Method Summary * Parameter types in italic indicate optional parameters | |
Number
|
addRow(<Array> cellValues)
Adds a row to the dataset. |
void
|
applySort(suppressEvent)
Applies the last used sort to the current data. |
Number
|
filter(<Object> query)
Filter the DataModel rows by the query defined in spec, see query() for more details on the query spec. |
Array
|
getRow(rowIndex)
Returns the column data for the specified row. |
Number
|
getRowCount()
Returns the number of rows in the dataset |
Number
|
getRowId(rowIndex)
Returns the ID of the specified row. |
Array
|
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. |
Object
|
getValueAt(<Number> rowIndex, <Number> colIndex)
Returns the value at the specified data position |
Number
|
insertRow(<Number> index, <Array> cellValues)
Inserts a row a the specified location in the dataset. |
Array
|
query(<Object> spec, <Boolean> returnUnmatched)
Query the DataModel rows by the filters defined in spec, for example... |
void
|
removeRow(<Number> index)
Remove a row. |
void
|
setDefaultSort(columnModel, columnIndex, direction)
|
void
|
setValueAt(<Object> value, <Number> rowIndex, <Number> colIndex)
Sets the specified value at the specified data position |
void
|
sort(<YAHOO.ext.grid.DefaultColumnModel> columnModel, <Number> columnIndex, <String> direction, suppressEvent)
Sorts the data by the specified column - Uses the sortType specified for the column in the passed columnModel. |
| Methods inherited from class YAHOO.ext.grid.AbstractDataModel |
fireCellUpdated, fireTableDataChanged, fireRowsDeleted, fireRowsInserted, fireRowsUpdated, fireRowsSorted, getSortState, getTotalRowCount, isPaged
|
| Constructor Detail |
YAHOO.ext.grid.DefaultDataModel(data)
| Method Detail |
Number addRow(<Array> cellValues)
cellValues - The array of values for the new row
void applySort(suppressEvent)
Number filter(<Object> query)
query - The query spec query()
Array getRow(rowIndex)
Number getRowCount()
Number getRowId(rowIndex)
Array getRows(<Array> indexes)
indexes - The row indexes to fetch
Object getValueAt(<Number> rowIndex, <Number> colIndex)
rowIndex -
colIndex -
Number insertRow(<Number> index, <Array> cellValues)
index - The index where the row should be inserted
cellValues - The array of values for the new row
Array query(<Object> spec, <Boolean> returnUnmatched)
// column 1 starts with Jack, column 2 filtered by myFcn, column 3 equals 'Fred'
dataModel.filter({1: /^Jack.+/i}, 2: myFcn, 3: 'Fred'});
spec - The 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.
returnUnmatched - True to return rows which don't match the query instead of rows that do match
void removeRow(<Number> index)
index -
void setDefaultSort(columnModel, columnIndex, direction)
void setValueAt(<Object> value, <Number> rowIndex, <Number> colIndex)
value - The new value
rowIndex -
colIndex -
void sort(<YAHOO.ext.grid.DefaultColumnModel> columnModel, <Number> columnIndex, <String> direction, suppressEvent)
columnModel - The ColumnModel for this dataset
columnIndex - The column index to sort by
direction - The direction of the sort ('DESC' or 'ASC')