| Package: | YAHOO.ext.grid |
| Class: | XMLDataModel |
| Extends: | LoadableDataModel |
| Defined In: | XMLDataModel.js |
var schema = {
tagName: 'Item',
id: 'ASIN',
fields: ['Author', 'Title', 'Manufacturer', 'ProductGroup']
};
| Property | Defined By | |
|---|---|---|
| baseParams : Object | LoadableDataModel | |
| An object of key/value pairs to be passed as parameters when loading pages/sorting | ||
| loadedPage : Number | LoadableDataModel | |
| The active page | ||
| pageSize : Number | LoadableDataModel | |
| The number of records per page | ||
| pageUrl : String | LoadableDataModel | |
| The script/page to call to provide paged/sorted data | ||
| paramMap : Object | LoadableDataModel | |
| Maps named params to url parameters - Override to specify your own param names | ||
| remoteSort : Boolean | LoadableDataModel | |
| True to use remote sorting, initPaging automatically sets this to true | ||
| sortTypes<static> : Object | DefaultDataModel | |
| <static> Alias to YAHOO.ext.grid.DefaultColumnModel.sortTypes | ||
| Method | Defined By | |
|---|---|---|
XMLDataModel(Object schema, XMLDocument xml) |
XMLDataModel | |
addListener(String eventName, Function handler, [Object scope], [boolean override]) : void |
Observable | |
| Appends an event handler to this element | ||
addPostprocessor(Number columnIndex, Function fn) : void |
LoadableDataModel | |
| Adds a postprocessor function to format data before updating the underlying data source (ie. convert date to string b... | ||
addPreprocessor(Number columnIndex, Function fn) : void |
LoadableDataModel | |
| Adds a preprocessor function to parse data before it is added to the Model - ie. Date.parse to parse dates. | ||
addRow(String id, Array cellValues) : Number |
XMLDataModel | |
| Adds a row to this DataModel and syncs the XML document | ||
| applySort() : void | DefaultDataModel | |
| Applies the last used sort to the current data. | ||
createNode(XMLDocument xmlDoc, String/Number id, Array colData) : XMLNode |
XMLDataModel | |
| Override this method to define your own node creation routine for when new rows are added. By default this method clo... | ||
delayedListener(String eventName, Function handler, [Object scope], [Number delay]) : Function |
Observable | |
| Appends an event handler to this element that is delayed the specified number of milliseconds. | ||
each(Function fn, [Object scope]) : 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. | ||
fireEvent(String eventName, Object... args) : Boolean |
Observable | |
| Fires the specified event with the passed parameters (minus the event name). | ||
| getPageSize() : Number | LoadableDataModel | |
| Returns the number of records per page | ||
getPostprocessor(Number columnIndex) : Function |
LoadableDataModel | |
| Gets the postprocessor function for the specified column. | ||
getPreprocessor(Number columnIndex) : Function |
LoadableDataModel | |
| Gets the preprocessor function for the specified column. | ||
| getRow() : Array | DefaultDataModel | |
| Returns the column data for the specified row. | ||
| getRowCount() : Number | DefaultDataModel | |
| Returns the number of rows in the dataset | ||
getRowId(Number rowIndex) : Number |
XMLDataModel | |
| Overrides getRowId in DefaultDataModel to return the ID value of the specified node. | ||
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 ... | ||
| getTotalPages() : Number | LoadableDataModel | |
| Returns the total number of pages available | ||
| getTotalRowCount() : Number | LoadableDataModel | |
| Returns the total number of records available, override if needed | ||
getValueAt(Number rowIndex, Number colIndex) : Object |
DefaultDataModel | |
| Returns the value at the specified data position | ||
initPaging(String url, Number pageSize, [Object baseParams]) : void |
LoadableDataModel | |
| Initializes paging for this model. | ||
insertRow(Number index, String id, Array cellValues) : Number |
XMLDataModel | |
| Inserts a row into this DataModel and syncs the XML document | ||
| isPaged() : Boolean | LoadableDataModel | |
| Returns true if this model uses paging | ||
load(Object/String url, [String/Object params], [Function callback], [Number insertIndex]) : void |
LoadableDataModel | |
| Initiates the loading of the data from the specified URL - Failed load attempts will fire the loadexception event. | ||
loadData(XMLDocument doc, [Function callback], [Boolean keepExisting], [Number insertIndex]) : void |
XMLDataModel | |
| Overrides loadData in LoadableDataModel to process XML | ||
loadPage(Number pageNum, [Function callback], [Boolean keepExisting]) : void |
LoadableDataModel | |
| Loads a page of data. | ||
| purgeListeners() : void | Observable | |
| Removes all listeners for this object | ||
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... | ||
removeListener(String eventName, Function handler, [Object scope]) : void |
Observable | |
| Removes a listener | ||
removePostprocessor(Number columnIndex) : void |
LoadableDataModel | |
| Removes a postprocessor function. | ||
removePreprocessor(Number columnIndex) : void |
LoadableDataModel | |
| Removes a preprocessor function. | ||
removeRow(Number index) : void |
XMLDataModel | |
| Removes the row from DataModel and syncs the XML document | ||
setDefaultSort(Function/Object sortInfo, Number columnIndex, String direction) : void |
DefaultDataModel | |
| Sets the default sort info. Note: this function does not actually apply the sort. | ||
setValueAt(Object value, Number rowIndex, Number colIndex) : void |
XMLDataModel | |
| Overrides DefaultDataModel.setValueAt to update the underlying XML Document | ||
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. | ||
| Event | Defined By | |
|---|---|---|
beforeload : (DataModel this) |
LoadableDataModel | |
| Fires before a load takes place | ||
cellupdated : (DataModel this, Number rowIndex, Number columnIndex) |
AbstractDataModel | |
| Fires when a cell is updated | ||
datachanged : (DataModel this) |
AbstractDataModel | |
| Fires when the entire data structure has changed | ||
load : (DataModel this) |
LoadableDataModel | |
| Fires when new data has successfully been loaded | ||
loadexception : (DataModel this, Exception e, Object response) |
LoadableDataModel | |
| Fires when there's an error loading data | ||
rowsdeleted : (DataModel this, Number firstRowIndex, Number lastRowIndex) |
AbstractDataModel | |
| Fires when a range of rows have been deleted | ||
rowsinserted : (DataModel this, Number firstRowIndex, Number lastRowIndex) |
AbstractDataModel | |
| Fires when a range of rows have been inserted | ||
rowssorted : (DataModel this) |
AbstractDataModel | |
| Fires when the data has been sorted | ||
rowsupdated : (DataModel this, Number firstRowIndex, Number lastRowIndex) |
AbstractDataModel | |
| Fires when a range of rows have been updated | ||
public Object baseParams
public Number pageSize
public String pageUrl
public Object paramMap
public Boolean remoteSort
public Object sortTypes<static>
public function XMLDataModel(Object schema, XMLDocument xml)
schema : Objectxml : XMLDocumentpublic function addListener(String eventName, Function handler, [Object scope], [boolean override])
eventName : Stringhandler : Functionscope : Objectoverride : booleanvoidpublic function addPostprocessor(Number columnIndex, Function fn)
columnIndex : Numberfn : Functionvoidpublic function addPreprocessor(Number columnIndex, Function fn)
columnIndex : Numberfn : Functionvoidpublic function addRow(String id, Array cellValues)
id : StringcellValues : ArrayNumberpublic function applySort()
voidpublic function createNode(XMLDocument xmlDoc, String/Number id, Array colData)
xmlDoc : XMLDocumentid : String/NumbercolData : ArrayXMLNodepublic function delayedListener(String eventName, Function handler, [Object scope], [Number delay])
eventName : Stringhandler : Functionscope : Objectdelay : NumberFunctionpublic function each(Function fn, [Object scope])
fn : Functionscope : Objectvoidpublic function filter(Object query)
query : ObjectNumberpublic function fireEvent(String eventName, Object... args)
eventName : Stringargs : Object...Booleanpublic function getPageSize()
Numberpublic function getPostprocessor(Number columnIndex)
columnIndex : NumberFunctionpublic function getPreprocessor(Number columnIndex)
columnIndex : NumberFunctionpublic function getRow()
Arraypublic function getRowCount()
Numberpublic function getRowId(Number rowIndex)
rowIndex : NumberNumberpublic function getRows(Array indexes)
indexes : ArrayArraypublic function getTotalPages()
Numberpublic function getTotalRowCount()
Numberpublic function getValueAt(Number rowIndex, Number colIndex)
rowIndex : NumbercolIndex : NumberObjectpublic function initPaging(String url, Number pageSize, [Object baseParams])
url : StringpageSize : NumberbaseParams : Objectvoidpublic function insertRow(Number index, String id, Array cellValues)
index : Numberid : StringcellValues : ArrayNumberpublic function isPaged()
Booleanpublic function load(Object/String url, [String/Object params], [Function callback], [Number insertIndex])
url : Object/Stringparams : String/Objectcallback : FunctioninsertIndex : Numbervoidpublic function loadData(XMLDocument doc, [Function callback], [Boolean keepExisting], [Number insertIndex])
doc : XMLDocumentcallback : FunctionkeepExisting : BooleaninsertIndex : Numbervoidpublic function loadPage(Number pageNum, [Function callback], [Boolean keepExisting])
pageNum : Numbercallback : FunctionkeepExisting : Booleanvoidpublic function purgeListeners()
voidpublic function 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 : ObjectreturnUnmatched : BooleanArraypublic function removeListener(String eventName, Function handler, [Object scope])
eventName : Stringhandler : Functionscope : Objectvoidpublic function removePostprocessor(Number columnIndex)
columnIndex : Numbervoidpublic function removePreprocessor(Number columnIndex)
columnIndex : Numbervoidpublic function removeRow(Number index)
index : Numbervoidpublic function setDefaultSort(Function/Object sortInfo, Number columnIndex, String direction)
sortInfo : Function/ObjectcolumnIndex : Numberdirection : Stringvoidpublic function setValueAt(Object value, Number rowIndex, Number colIndex)
value : ObjectrowIndex : NumbercolIndex : Numbervoidpublic function sort(Function/Object sortInfo, Number columnIndex, String direction)
sortInfo : Function/ObjectcolumnIndex : Numberdirection : Stringvoidpublic event beforeload
this : DataModelpublic event cellupdated
this : DataModelrowIndex : NumbercolumnIndex : Numberpublic event datachanged
this : DataModelpublic event load
this : DataModelpublic event loadexception
this : DataModele : Exceptionresponse : Objectpublic event rowsdeleted
this : DataModelfirstRowIndex : NumberlastRowIndex : Numberpublic event rowsinserted
this : DataModelfirstRowIndex : NumberlastRowIndex : Numberpublic event rowssorted
this : DataModelpublic event rowsupdated
this : DataModelfirstRowIndex : NumberlastRowIndex : Number