/** * @class YAHOO.ext.grid.AbstractDataModel * This abstract class provides default implementations of the events required by the Grid. It takes care of the creating the CustomEvents and provides some convenient methods for firing the events. <br><br> * @constructor */ YAHOO.ext.grid.AbstractDataModel = function(){ /** Fires when a cell is updated - fireDirect sig: (this, rowIndex, columnIndex) * @type YAHOO.util.CustomEvent * @deprecated Use addListener instead of accessing directly */ this.onCellUpdated = new YAHOO.util.CustomEvent('onCellUpdated'); /** Fires when all data needs to be revalidated - fireDirect sig: (thisd) * @type YAHOO.util.CustomEvent * @deprecated Use addListener instead of accessing directly */ this.onTableDataChanged = new YAHOO.util.CustomEvent('onTableDataChanged'); /** Fires when rows are deleted - fireDirect sig: (this, firstRowIndex, lastRowIndex) * @type YAHOO.util.CustomEvent * @deprecated Use addListener instead of accessing directly */ this.onRowsDeleted = new YAHOO.util.CustomEvent('onRowsDeleted'); /** Fires when a rows are inserted - fireDirect sig: (this, firstRowIndex, lastRowIndex) * @type YAHOO.util.CustomEvent * @deprecated Use addListener instead of accessing directly */ this.onRowsInserted = new YAHOO.util.CustomEvent('onRowsInserted'); /** Fires when a rows are updated - fireDirect sig: (this, firstRowIndex, lastRowIndex) * @type YAHOO.util.CustomEvent * @deprecated Use addListener instead of accessing directly */ this.onRowsUpdated = new YAHOO.util.CustomEvent('onRowsUpdated'); /** Fires when a sort has reordered the rows - fireDirect sig: (this, sortColumnIndex, * sortDirection = 'ASC' or 'DESC') * @type YAHOO.util.CustomEvent * @deprecated Use addListener instead of accessing directly */ this.onRowsSorted = new YAHOO.util.CustomEvent('onRowsSorted'); this.events = { 'cellupdated' : this.onCellUpdated, 'datachanged' : this.onTableDataChanged, 'rowsdeleted' : this.onRowsDeleted, 'rowsinserted' : this.onRowsInserted, 'rowsupdated' : this.onRowsUpdated, 'rowssorted' : this.onRowsSorted }; }; YAHOO.ext.grid.AbstractDataModel.prototype = { /** Inherited from Observable */ fireEvent : YAHOO.ext.util.Observable.prototype.fireEvent, /** Inherited from Observable */ on : YAHOO.ext.util.Observable.prototype.on, /** Inherited from Observable */ addListener : YAHOO.ext.util.Observable.prototype.addListener, /** Inherited from Observable */ delayedListener : YAHOO.ext.util.Observable.prototype.delayedListener, /** Inherited from Observable */ removeListener : YAHOO.ext.util.Observable.prototype.removeListener, /** * Notifies listeners that the value of the cell at [row, col] has been updated */ fireCellUpdated : function(row, col){ this.onCellUpdated.fireDirect(this, row, col); }, /** * 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. */ fireTableDataChanged : function(){ this.onTableDataChanged.fireDirect(this); }, /** * Notifies listeners that rows in the range [firstRow, lastRow], inclusive, have been deleted */ fireRowsDeleted : function(firstRow, lastRow){ this.onRowsDeleted.fireDirect(this, firstRow, lastRow); }, /** * Notifies listeners that rows in the range [firstRow, lastRow], inclusive, have been inserted */ fireRowsInserted : function(firstRow, lastRow){ this.onRowsInserted.fireDirect(this, firstRow, lastRow); }, /** * Notifies listeners that rows in the range [firstRow, lastRow], inclusive, have been updated */ fireRowsUpdated : function(firstRow, lastRow){ this.onRowsUpdated.fireDirect(this, firstRow, lastRow); }, /** * Notifies listeners that rows have been sorted and any indexes may be invalid */ fireRowsSorted : function(sortColumnIndex, sortDir, noRefresh){ this.onRowsSorted.fireDirect(this, sortColumnIndex, sortDir, noRefresh); }, /** * Empty interface method - Classes which extend AbstractDataModel should implement this method. * See {@link YAHOO.ext.DefaultDataModel} for an example implementation. */ sort : function(sortInfo, columnIndex, direction, suppressEvent){ }, /** * 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}. * @return {Object} */ getSortState : function(){ return {column: this.sortColumn, direction: this.sortDir}; }, /** * Empty interface method - Classes which extend AbstractDataModel should implement this method. * See {@link YAHOO.ext.DefaultDataModel} for an example implementation. */ getRowCount : function(){ }, /** * Empty interface method - Classes which extend AbstractDataModel should implement this method to support virtual row counts. */ getTotalRowCount : function(){ return this.getRowCount(); }, /** * Empty interface method - Classes which extend AbstractDataModel should implement this method. * See {@link YAHOO.ext.DefaultDataModel} for an example implementation. */ getRowId : function(rowIndex){ }, /** * Empty interface method - Classes which extend AbstractDataModel should implement this method. * See {@link YAHOO.ext.DefaultDataModel} for an example implementation. */ getValueAt : function(rowIndex, colIndex){ }, /** * Empty interface method - Classes which extend AbstractDataModel should implement this method. * See {@link YAHOO.ext.DefaultDataModel} for an example implementation. */ setValueAt : function(value, rowIndex, colIndex){ }, isPaged : function(){ return false; } };