dojo/data
- 主要定义了dojo/data的接口结构,以及最基本的几个util
1. dojo/data/api
- 定义接口结构
1.1. Read.js
@L_301_2@
1.1.1. 依赖
dojo.require("dojo.data.api.Request");
1.1.2. 成员函数
getValue: function( /* item */ item,/* attribute-name-string */ attribute,/* value? */ defaultValue)
- 摘要:
- 描述:如果 store.hasAttribute(item,attribute) 返回 false,则 store.getValue(item,attribute) 将返回undefined
- 异常:当item并不是item类型,或attribute不是字符串时,抛出异常。
- 举例:
var darthVader = store.getValue(lukeSkywalker,"father");
getValues: function(/* item */ item,/* attribute-name-string */ attribute)
- 摘要:
- 举例:
var friendsOfLuke = store.getValues(lukeSkywalker,"friends");
getAttributes: function(/* item */ item)
hasAttribute: function( /* item */ item,/* attribute-name-string */ attribute)
- 摘要:如果item中包含指定的attribute属性,则返回true,否则返回false
- 举例:
var trueOrFalse = store.hasAttribute(kermit,"color");
containsValue: function(/* item */ item,/* anything */ value)
- 摘要:如果value的值是那个item使用getValues()所返回的值数组中的一个,则这个函数返回true
- 举例:
var trueOrFalse = store.containsValue(kermit,"color","green");
isItem: function(/* anything */ something)
- 摘要: 如果somethind是一个item并且是从指定的store对象实例化而来的,就返回true,否则返回false
- 举例:
var yes = store.isItem(store.newItem());
var no = store.isItem("green");
isItemLoaded: function(/* anything */ something)
- 摘要:
- 举例:
var yes = store.isItemLoaded(store.newItem());
var no = store.isItemLoaded("green");
loadItem: function(/* object */ keywordArgs)
- 摘要:
- keywordArgs:
fetch: function(/* Object */ keywordArgs)
- 摘要: 给定查询query,以及一些预定义的选项,比如返回item的start和count,这个函数就会自动执行查询,并把返回结果作为数据items返回。
- 描述:
- keywordsArgs:
- query: query-string or query-object,
- queryOptions: object,
- onBegin: Function,
- onItem: Function,
- onComplete: Function,
- onError: Function,
- scope: object,
- start: int
- count: int
- sort: array
getFeatures: function()
- 摘要:
- 返回这个接口实现的特性
- 可能是如下'dojo.data.api.Read','dojo.data.api.Write','dojo.data.api.Identity',and 'dojo.data.api.Attribution'
close: function(/*dojo.data.api.Request || keywordArgs || null */ request)
- 举例:
var request = store.fetch({onComplete: doSomething});
...
store.close(request);
getLabel: function(/* item */ item)
getLabelAttributes: function(/* item */ item)
1.2. Write.js
1.2.1. 依赖
dojo.require("dojo.data.api.Read");
1.2.2 成员函数
getFeatures: function()
- 同data.Read.getFeatuers()
newItem: function(/* Object? */ keywordArgs,/*Object?*/ parentInfo)
- 摘要:
- 返回一个新创建的item
- 通过keywordsArgs参数来设置新对象的属性
- parentInfo: 可选的,定义当前创建的item的父节点
- parent: someItem
- attribute: "attribute-name-string"
- 举例:
var kermit = store.newItem({name: "Kermit",color:[blue,green]});
deleteItem: function(/* item */ item)
- 举例:
var success = store.deleteItem(kermit)
setValue: function( /* item */ item,/* string */ attribute,/* almost anything */ value)
setValues: function(/* item */ item,/* array */ values)
- 摘要:
- 举例:
var success = store.setValues(kermit,["green","aqua"]);
success = store.setValues(kermit,[]);
if (success) {assert(!store.hasAttribute(kermit,"color"));}
unsetAttribute: function( /* item */ item,/* string */ attribute)
- 摘要: 删除指定item的指定属性上的全部值
- 举例:
var success = store.unsetAttribute(kermit,"color");
if (success) {assert(!store.hasAttribute(kermit,"color"));}
save: function(/* object */ keywordArgs)
- 摘要:
- keywordsArgs
- onComplete: function()
- onError: function(errorData)
- scope: object
- 举例:
store.save({onComplete: onSave});
store.save({scope: fooObj,onComplete: onSave,onError: saveFailed});
revert: function()
isDirty: function(/* item? */ item)
- 摘要:
- 举例:
var trueOrFalse = store.isDirty(kermit); // true if kermit is dirty
var trueOrFalse = store.isDirty(); // true if any item is dirty
1.3. Identity.js (ToBeContinued)
1.4. Notification.js (ToBeContinued)
1.5. Request.js (ToBeContinued)
2. dojo/data/util
2.1. filter.js
dojo.data.util.filter.patternToRegExp = function(/*String*/pattern,/*boolean?*/ ignoreCase)