Clear Up
SharpKit Reference

ModelConfig Class

Namespace: Ext.data

Base Types

System.Object

Constructors

Name Description
ModelConfig(Object[])

Fields

Name Description
associations An array of associations for this model.
belongsTo One or more BelongsTo associations for this model.
clientIdProperty The name of a property that is used for submitting this Model's unique client-side identifier to the server when multiple phantom records are saved as part of the same Operation. In such a case, the server response should include the client id for each record so that the server response data can be used to update the client-side records if necessary. This property cannot have the same name as any of this Model's fields. Defaults to: null
defaultProxyType The string type of the default Model Proxy. Defaults to 'ajax'. Defaults to: "ajax"
fields The fields for this model. This is an Array of Field definition objects. A Field definition may simply be the name of the Field, but a Field encapsulates data type, custom conversion of raw data, and a mapping property to specify by name of index, how to extract a field's value from a raw data object, so it is best practice to specify a full set of Field config objects.
hasMany One or more HasMany associations for this model.
idgen The id generator to use for this model. The default id generator does not generate values for the idProperty. This can be overridden at the model level to provide a custom generator for a model. The simplest form of this would be:
  Ext.define('MyApp.data.MyModel', {
            extend: 'Ext.data.Model',
            requires: ['Ext.data.SequentialIdGenerator'],
            idgen: 'sequential',
            ...
            });
            
The above would generate sequential id's such as 1, 2, 3 etc.. Another useful id generator is Ext.data.UuidGenerator:
  Ext.define('MyApp.data.MyModel', {
            extend: 'Ext.data.Model',
            requires: ['Ext.data.UuidGenerator'],
            idgen: 'uuid',
            ...
            });
            
An id generation can also be further configured:
  Ext.define('MyApp.data.MyModel', {
            extend: 'Ext.data.Model',
            idgen: {
            type: 'sequential',
            seed: 1000,
            prefix: 'ID_'
            }
            });
            
The above would generate id's such as ID_1000, ID_1001, ID_1002 etc.. If multiple models share an id space, a single generator can be shared:
  Ext.define('MyApp.data.MyModelX', {
            extend: 'Ext.data.Model',
            idgen: {
            type: 'sequential',
            id: 'xy'
            }
            });
            Ext.define('MyApp.data.MyModelY', {
            extend: 'Ext.data.Model',
            idgen: {
            type: 'sequential',
            id: 'xy'
            }
            });
            
For more complex, shared id generators, a custom generator is the best approach. See Ext.data.IdGenerator for details on creating custom id generators.
idProperty The name of the field treated as this Model's unique id. Defaults to 'id'. Defaults to: "id"
listeners A config object containing one or more event handlers to be added to this object during initialization. This should be a valid listeners config object as specified in the addListener example for attaching multiple handlers at once. DOM events from Ext JS Components While some Ext JS Component classes export selected DOM events (e.g. "click", "mouseover" etc), this is usually only done when extra value can be added. For example the DataView's itemclick event passing the node clicked on. To access DOM events directly from a child element of a Component, we need to specify the element option to identify the Component property to add a DOM listener to:
new Ext.panel.Panel({
            width: 400,
            height: 200,
            dockedItems: [{
            xtype: 'toolbar'
            }],
            listeners: {
            click: {
            element: 'el', //bind to the underlying el property on the panel
            fn: function(){ console.log('click el'); }
            },
            dblclick: {
            element: 'body', //bind to the underlying body property on the panel
            fn: function(){ console.log('dblclick body'); }
            }
            }
            });
            
persistenceProperty The name of the property on this Persistable object that its data is saved to. Defaults to 'data' (i.e: all persistable data resides in this.data.) Defaults to: "data"
proxy The proxy to use for this model.
validations An array of validations for this model.
© Copyright 2005-2011 SharpKit. All rights reserved.