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 |
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 component | ||
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. | ||
bufferedListener(String eventName , Function handler , [Object scope ], [Number millis ]) : Function |
Observable | |
Appends an event handler to this component that is buffered. If the event is triggered more than once in the specifie... | ||
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 component that is delayed the specified number of milliseconds. This is useful for e... | ||
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 ... | ||
getSortState() : Object | AbstractDataModel | |
Interface method to supply info regarding the Grid's current sort state - if overridden, this should return an object... | ||
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. | ||
on(String eventName , Function handler , [Object scope ], [boolean override ]) : void |
Observable | |
Appends an event handler to this element (shorthand for addListener) | ||
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 function XMLDataModel(Object schema
, XMLDocument xml
)
schema
: Objectxml
: XMLDocumentpublic function addListener(String eventName
, Function handler
, [Object scope
], [boolean override
])
eventName
: Stringhandler
: Functionscope
: Objectoverride
: booleanvoid
public function addPostprocessor(Number columnIndex
, Function fn
)
columnIndex
: Numberfn
: Functionvoid
public function addPreprocessor(Number columnIndex
, Function fn
)
columnIndex
: Numberfn
: Functionvoid
public function addRow(String id
, Array cellValues
)
id
: StringcellValues
: ArrayNumber
public function applySort()
void
public function bufferedListener(String eventName
, Function handler
, [Object scope
], [Number millis
])
eventName
: Stringhandler
: Functionscope
: Objectmillis
: NumberFunction
public function createNode(XMLDocument xmlDoc
, String/Number id
, Array colData
)
xmlDoc
: XMLDocumentid
: String/NumbercolData
: ArrayXMLNode
public function delayedListener(String eventName
, Function handler
, [Object scope
], [Number delay
])
eventName
: Stringhandler
: Functionscope
: Objectdelay
: NumberFunction
public function each(Function fn
, [Object scope
])
fn
: Functionscope
: Objectvoid
public function filter(Object query
)
query
: ObjectNumber
public function fireEvent(String eventName
, Object... args
)
eventName
: Stringargs
: Object...Boolean
public function getPageSize()
Number
public function getPostprocessor(Number columnIndex
)
columnIndex
: NumberFunction
public function getPreprocessor(Number columnIndex
)
columnIndex
: NumberFunction
public function getRow()
Array
public function getRowCount()
Number
public function getRowId(Number rowIndex
)
rowIndex
: NumberNumber
public function getRows(Array indexes
)
indexes
: ArrayArray
public function getSortState()
Object
public function getTotalPages()
Number
public function getTotalRowCount()
Number
public function getValueAt(Number rowIndex
, Number colIndex
)
rowIndex
: NumbercolIndex
: NumberObject
public function initPaging(String url
, Number pageSize
, [Object baseParams
])
url
: StringpageSize
: NumberbaseParams
: Objectvoid
public function insertRow(Number index
, String id
, Array cellValues
)
index
: Numberid
: StringcellValues
: ArrayNumber
public function isPaged()
Boolean
public function load(Object/String url
, [String/Object params
], [Function callback
], [Number insertIndex
])
url
: Object/Stringparams
: String/Objectcallback
: FunctioninsertIndex
: Numbervoid
public function loadData(XMLDocument doc
, [Function callback
], [Boolean keepExisting
], [Number insertIndex
])
doc
: XMLDocumentcallback
: FunctionkeepExisting
: BooleaninsertIndex
: Numbervoid
public function loadPage(Number pageNum
, [Function callback
], [Boolean keepExisting
])
pageNum
: Numbercallback
: FunctionkeepExisting
: Booleanvoid
public function on(String eventName
, Function handler
, [Object scope
], [boolean override
])
eventName
: Stringhandler
: Functionscope
: Objectoverride
: booleanvoid
public function purgeListeners()
void
public 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
: BooleanArray
public function removeListener(String eventName
, Function handler
, [Object scope
])
eventName
: Stringhandler
: Functionscope
: Objectvoid
public function removePostprocessor(Number columnIndex
)
columnIndex
: Numbervoid
public function removePreprocessor(Number columnIndex
)
columnIndex
: Numbervoid
public function removeRow(Number index
)
index
: Numbervoid
public function setDefaultSort(Function/Object sortInfo
, Number columnIndex
, String direction
)
sortInfo
: Function/ObjectcolumnIndex
: Numberdirection
: Stringvoid
public function setValueAt(Object value
, Number rowIndex
, Number colIndex
)
value
: ObjectrowIndex
: NumbercolIndex
: Numbervoid
public function sort(Function/Object sortInfo
, Number columnIndex
, String direction
)
sortInfo
: Function/ObjectcolumnIndex
: Numberdirection
: Stringvoid
public 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