X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/0494b8d9b9bb03ab6c22b34dae81261e3cd7e3e6..7a654f8d43fdb43d78b63d90528bed6e86b608cc:/docs/api/Ext.ModelManager.html diff --git a/docs/api/Ext.ModelManager.html b/docs/api/Ext.ModelManager.html new file mode 100644 index 00000000..97a10f61 --- /dev/null +++ b/docs/api/Ext.ModelManager.html @@ -0,0 +1,156 @@ +Ext.ModelManager | Ext JS 4.0 Documentation +
For up to date documentation and features, visit +http://docs.sencha.com/ext-js/4-0

Sencha Documentation

+ + + + + +

Hierarchy

Ext.AbstractManager
Ext.ModelManager

The ModelManager keeps track of all Ext.data.Model types defined in your application.

+ +

Creating Model Instances +Model instances can be created by using the create function. It is also possible to do +this by using the Model type directly. The following snippets are equivalent:

+ +
Ext.define('User', {
+    extend: 'Ext.data.Model',
+    fields: ['first', 'last']
+});
+
+// method 1, create through the manager
+Ext.ModelManager.create({
+    first: 'Ed',
+    last: 'Spencer'
+}, 'User');
+
+// method 2, create on the type directly
+new User({
+    first: 'Ed',
+    last: 'Spencer'
+});
+
+ +

Accessing Model Types +A reference to a Model type can be obtained by using the getModel function. Since models types +are normal classes, you can access the type directly. The following snippets are equivalent:

+ +
Ext.define('User', {
+    extend: 'Ext.data.Model',
+    fields: ['first', 'last']
+});
+
+// method 1, access model type through the manager
+var UserType = Ext.ModelManager.getModel('User');
+
+// method 2, reference the type directly
+var UserType = User;
+
+
Defined By

Properties

 
all : Ext.util.MixedCollection

Contains all of the items currently managed

+

Contains all of the items currently managed

+
 

Private stack of associations that must be created once their associated model has been defined

+

Private stack of associations that must be created once their associated model has been defined

+
Defined By

Methods

 
create( +Object data, String name, Number id) + : void

Creates a new instance of a Model using the given data.

+

Creates a new instance of a Model using the given data.

+

Parameters

  • data : Object

    Data to initialize the Model's fields with

    +
  • name : String

    The name of the model to create

    +
  • id : Number

    Optional unique id of the Model instance (see Ext.data.Model)

    +

Returns

  • void    +
 
each( +Object fn, Object scope) + : void
Executes the specified function once for each item in the collection. +Returning false from the function will cease it...

Executes the specified function once for each item in the collection. +Returning false from the function will cease iteration.

+ +

The paramaters passed to the function are:

+ +
    +
  • key : String

    The key of the item

  • +
  • value : Number

    The value of the item

  • +
  • length : Number

    The total number of items in the collection

  • +
+ +

Parameters

  • fn : Object

    The function to execute.

    +
  • scope : Object

    The scope to execute in. Defaults to this.

    +

Returns

  • void    +
 
get( +String id) + : Mixed

Returns an item by id. +For additional details see Ext.util.HashMap.get.

+

Returns an item by id. +For additional details see Ext.util.HashMap.get.

+

Parameters

  • id : String

    The id of the item

    +

Returns

  • Mixed   

    The item, undefined if not found.

    +
 

Gets the number of items in the collection.

+

Gets the number of items in the collection.

+

Returns

  • Number   

    The number of items in the collection.

    +
 
getModel( +String/Object id) + : void

Returns the Ext.data.Model for a given model name

+

Returns the Ext.data.Model for a given model name

+

Parameters

  • id : String/Object

    The id of the model or the model instance.

    +

Returns

  • void    +
 

Checks if an item type is registered.

+

Checks if an item type is registered.

+

Parameters

  • type : String

    The mnemonic string by which the class may be looked up

    +

Returns

  • Boolean   

    Whether the type is registered.

    +
 
onAvailable( +String id, Function fn, Object scope) + : void
Registers a function that will be called when an item with the specified id is added to the manager. This will happen...

Registers a function that will be called when an item with the specified id is added to the manager. This will happen on instantiation.

+

Parameters

  • id : String

    The item id

    +
  • fn : Function

    The callback function. Called with a single parameter, the item.

    +
  • scope : Object

    The scope (this reference) in which the callback is executed. Defaults to the item.

    +

Returns

  • void    +
 

Registers an item to be managed

+

Registers an item to be managed

+

Parameters

  • item : Mixed

    The item to register

    +

Returns

  • void    +
 
registerType( +String type, Constructor cls) + : void

Registers a new item constructor, keyed by a type key. + +

Registers a new item constructor, keyed by a type key. + +

Parameters

  • type : String

    The mnemonic string by which the class may be looked up.

    +
  • cls : Constructor

    The new instance class.

    +

Returns

  • void    +
 

Unregisters an item by removing it from this manager

+

Unregisters an item by removing it from this manager

+

Parameters

  • item : Mixed

    The item to unregister

    +

Returns

  • void    +
\ No newline at end of file