Ext.data.JsonP.Ext_data_Field({"mixins":[],"code_type":"ext_define","inheritable":false,"component":false,"meta":{"author":["Ed Spencer"]},"mixedInto":[],"uses":[],"aliases":{"data":["field"]},"parentMixins":[],"superclasses":["Ext.Base"],"members":{"event":[],"property":[{"meta":{"private":true},"owner":"Ext.Base","tagname":"property","name":"$className","id":"property-S-className"},{"meta":{"private":true},"owner":"Ext.Base","tagname":"property","name":"configMap","id":"property-configMap"},{"meta":{"private":true},"owner":"Ext.Base","tagname":"property","name":"initConfigList","id":"property-initConfigList"},{"meta":{"private":true},"owner":"Ext.Base","tagname":"property","name":"initConfigMap","id":"property-initConfigMap"},{"meta":{"private":true},"owner":"Ext.Base","tagname":"property","name":"isInstance","id":"property-isInstance"},{"meta":{"protected":true},"owner":"Ext.Base","tagname":"property","name":"self","id":"property-self"}],"css_var":[],"method":[{"meta":{"deprecated":{"text":"as of 4.1. Use {@link #callParent} instead."},"protected":true},"owner":"Ext.Base","tagname":"method","name":"callOverridden","id":"method-callOverridden"},{"meta":{"protected":true},"owner":"Ext.Base","tagname":"method","name":"callParent","id":"method-callParent"},{"meta":{"private":true},"owner":"Ext.Base","tagname":"method","name":"configClass","id":"method-configClass"},{"meta":{"private":true},"owner":"Ext.Base","tagname":"method","name":"destroy","id":"method-destroy"},{"meta":{"private":true},"owner":"Ext.Base","tagname":"method","name":"getConfig","id":"method-getConfig"},{"meta":{},"owner":"Ext.Base","tagname":"method","name":"getInitialConfig","id":"method-getInitialConfig"},{"meta":{"private":true},"owner":"Ext.Base","tagname":"method","name":"hasConfig","id":"method-hasConfig"},{"meta":{"protected":true},"owner":"Ext.Base","tagname":"method","name":"initConfig","id":"method-initConfig"},{"meta":{"private":true},"owner":"Ext.Base","tagname":"method","name":"onConfigUpdate","id":"method-onConfigUpdate"},{"meta":{"private":true},"owner":"Ext.Base","tagname":"method","name":"setConfig","id":"method-setConfig"},{"meta":{"protected":true},"owner":"Ext.Base","tagname":"method","name":"statics","id":"method-statics"}],"css_mixin":[],"cfg":[{"meta":{"private":true},"owner":"Ext.data.Field","tagname":"cfg","name":"allowBlank","id":"cfg-allowBlank"},{"meta":{},"owner":"Ext.data.Field","tagname":"cfg","name":"convert","id":"cfg-convert"},{"meta":{},"owner":"Ext.data.Field","tagname":"cfg","name":"dateFormat","id":"cfg-dateFormat"},{"meta":{},"owner":"Ext.data.Field","tagname":"cfg","name":"defaultValue","id":"cfg-defaultValue"},{"meta":{},"owner":"Ext.data.Field","tagname":"cfg","name":"mapping","id":"cfg-mapping"},{"meta":{},"owner":"Ext.data.Field","tagname":"cfg","name":"name","id":"cfg-name"},{"meta":{},"owner":"Ext.data.Field","tagname":"cfg","name":"persist","id":"cfg-persist"},{"meta":{},"owner":"Ext.data.Field","tagname":"cfg","name":"serialize","id":"cfg-serialize"},{"meta":{},"owner":"Ext.data.Field","tagname":"cfg","name":"sortDir","id":"cfg-sortDir"},{"meta":{},"owner":"Ext.data.Field","tagname":"cfg","name":"sortType","id":"cfg-sortType"},{"meta":{},"owner":"Ext.data.Field","tagname":"cfg","name":"type","id":"cfg-type"},{"meta":{},"owner":"Ext.data.Field","tagname":"cfg","name":"useNull","id":"cfg-useNull"}]},"tagname":"class","extends":"Ext.Base","html":"
Hierarchy
Ext.BaseExt.data.FieldRequires
Files
Fields are used to define what a Model is. They aren't instantiated directly - instead, when we create a class that\nextends Ext.data.Model, it will automatically create a Field instance for each field configured in a Model. For example, we might set up a model like this:
\n\nExt.define('User', {\n extend: 'Ext.data.Model',\n fields: [\n 'name', 'email',\n {name: 'age', type: 'int'},\n {name: 'gender', type: 'string', defaultValue: 'Unknown'}\n ]\n});\n
\n\nFour fields will have been created for the User Model - name, email, age and gender. Note that we specified a couple\nof different formats here; if we only pass in the string name of the field (as with name and email), the field is set\nup with the 'auto' type. It's as if we'd done this instead:
\n\nExt.define('User', {\n extend: 'Ext.data.Model',\n fields: [\n {name: 'name', type: 'auto'},\n {name: 'email', type: 'auto'},\n {name: 'age', type: 'int'},\n {name: 'gender', type: 'string', defaultValue: 'Unknown'}\n ]\n});\n
\n\nThe type is important - it's used to automatically convert data passed to the field into the correct format.\nIn our example above, the name and email fields used the 'auto' type and will just accept anything that is passed\ninto them. The 'age' field had an 'int' type however, so if we passed 25.4 this would be rounded to 25.
\n\nSometimes a simple type isn't enough, or we want to perform some processing when we load a Field's data. We can do\nthis using a convert function. Here, we're going to create a new field based on another:
\n\nExt.define('User', {\n extend: 'Ext.data.Model',\n fields: [\n {\n name: 'firstName',\n convert: function(value, record) {\n var fullName = record.get('name'),\n splits = fullName.split(\" \"),\n firstName = splits[0];\n\n return firstName;\n }\n },\n 'name', 'email',\n {name: 'age', type: 'int'},\n {name: 'gender', type: 'string', defaultValue: 'Unknown'}\n ]\n});\n
\n\nNow when we create a new User, the firstName is populated automatically based on the name:
\n\nvar ed = Ext.create('User', {name: 'Ed Spencer'});\n\nconsole.log(ed.get('firstName')); //logs 'Ed', based on our convert function\n
\n\nFields which are configured with a custom convert
function are read after all other fields\nwhen constructing and reading records, so that if convert functions rely on other, non-converted fields\n(as in this example), they can be sure of those fields being present.
In fact, if we log out all of the data inside ed, we'll see this:
\n\nconsole.log(ed.data);\n\n//outputs this:\n{\n age: 0,\n email: \"\",\n firstName: \"Ed\",\n gender: \"Unknown\",\n name: \"Ed Spencer\"\n}\n
\n\nThe age field has been given a default of zero because we made it an int type. As an auto field, email has defaulted\nto an empty string. When we registered the User model we set gender's defaultValue to 'Unknown' so we see\nthat now. Let's correct that and satisfy ourselves that the types work as we expect:
\n\ned.set('gender', 'Male');\ned.get('gender'); //returns 'Male'\n\ned.set('age', 25.4);\ned.get('age'); //returns 25 - we wanted an int, not a float, so no decimal places allowed\n
\nUsed for validating a model. Defaults to true. An empty value here will cause\nExt.data.Model.isValid to evaluate to false.
\nDefaults to: true
A function which converts the value provided by the Reader into an object that will be stored in the Model.
\n\nIf configured as null
, then no conversion will be applied to the raw data property when this Field\nis read. This will increase performance. but you must ensure that the data is of the correct type and does\nnot need converting.
It is passed the following parameters:
\n\nv : Mixed
\n\nThe data value as read by the Reader, if undefined will use the configured defaultValue
.
rec : Ext.data.Model
\n\nThe data object containing the Model as read so far by the Reader. Note that the Model may not be fully populated\nat this point as the fields are read in the order that they are defined in your\nfields array.
Example of convert functions:
\n\nfunction fullName(v, record){\n return record.data.last + ', ' + record.data.first;\n}\n\nfunction location(v, record){\n return !record.data.city ? '' : (record.data.city + ', ' + record.data.state);\n}\n\nExt.define('Dude', {\n extend: 'Ext.data.Model',\n fields: [\n {name: 'fullname', convert: fullName},\n {name: 'firstname', mapping: 'name.first'},\n {name: 'lastname', mapping: 'name.last'},\n {name: 'city', defaultValue: 'homeless'},\n 'state',\n {name: 'location', convert: location}\n ]\n});\n\n// create the data store\nvar store = Ext.create('Ext.data.Store', {\n reader: {\n type: 'json',\n model: 'Dude',\n idProperty: 'key',\n root: 'daRoot',\n totalProperty: 'total'\n }\n});\n\nvar myData = [\n { key: 1,\n name: { first: 'Fat', last: 'Albert' }\n // notice no city, state provided in data object\n },\n { key: 2,\n name: { first: 'Barney', last: 'Rubble' },\n city: 'Bedrock', state: 'Stoneridge'\n },\n { key: 3,\n name: { first: 'Cliff', last: 'Claven' },\n city: 'Boston', state: 'MA'\n }\n];\n
\nUsed when converting received data into a Date when the type is specified as \"date\"
.
The format dtring is also used when serializing Date fields for use by Writers.
\n\nA format string for the Ext.Date.parse function, or \"timestamp\" if the value provided by\nthe Reader is a UNIX timestamp, or \"time\" if the value provided by the Reader is a javascript millisecond\ntimestamp. See Ext.Date.
\nDefaults to: null
The default value used when the creating an instance from a raw data object, and the property referenced by the\nmapping
does not exist in that data object.
May be specified as undefined
to prevent defaulting in a value.
Defaults to: ""
(Optional) A path expression for use by the Ext.data.reader.Reader implementation that is creating the\nModel to extract the Field value from the data object. If the path expression is the same\nas the field name, the mapping may be omitted.
\n\nThe form of the mapping expression depends on the Reader being used.
\n\nThe mapping is a string containing the javascript expression to reference the data from an element of the data\nitem's root Array. Defaults to the field name.
The mapping is an Ext.DomQuery path to the data item relative to the DOM element that represents the\nrecord. Defaults to the field name.
The mapping is a number indicating the Array index of the field's value. Defaults to the field specification's\nArray position.
If a more complex value extraction strategy is required, then configure the Field with a convert\nfunction. This is passed the whole row object, and may interrogate it in whatever way is necessary in order to\nreturn the desired data.
\nDefaults to: null
The name by which the field is referenced within the Model. This is referenced by, for example, the dataIndex
\nproperty in column definition objects passed to Ext.grid.property.HeaderContainer.
Note: In the simplest case, if no properties other than name
are required, a field definition may consist of\njust a String for the field name.
False to exclude this field from the Ext.data.Model.modified fields in a model. This will also exclude\nthe field from being written using a Ext.data.writer.Writer. This option is useful when model fields are\nused to keep state on the client but do not need to be persisted to the server. Defaults to true.
\nDefaults to: true
A function which converts the Model's value for this Field into a form which can be used by whatever Writer\nis being used to sync data with the server.
\n\nThe function should return a string which represents the Field's value.
\n\nIt is passed the following parameters:
\n\nv : Mixed
\n\nThe Field's value - the value to be serialized.
rec : Ext.data.Model
\n\nThe record being serialized.
Initial direction to sort (\"ASC\"
or \"DESC\"
). Defaults to \"ASC\"
.
Defaults to: "ASC"
A function which converts a Field's value to a comparable value in order to ensure correct sort ordering.\nPredefined functions are provided in Ext.data.SortTypes. A custom sort example:
\n\n// current sort after sort we want\n// +-+------+ +-+------+\n// |1|First | |1|First |\n// |2|Last | |3|Second|\n// |3|Second| |2|Last |\n// +-+------+ +-+------+\n\nsortType: function(value) {\n switch (value.toLowerCase()) // native toLowerCase():\n {\n case 'first': return 1;\n case 'second': return 2;\n default: return 3;\n }\n}\n
\nDefaults to: null
The data type for automatic conversion from received data to the stored value if\nconvert
has not been specified. This may be specified as a string value.\nPossible values are
This may also be specified by referencing a member of the Ext.data.Types class.
\n\nDevelopers may create their own application-specific data types by defining new members of the Ext.data.Types class.
\nUse when converting received data into a INT, FLOAT, BOOL or STRING type. If the value cannot be\nparsed, null
will be used if useNull is true, otherwise a default value for that type will be used:
0
.\"\"
.false
.Note that when parsing of DATE type fails, the value will be null
regardless of this setting.
Defaults to: false
Get the reference to the current class from which this object was instantiated. Unlike statics,\nthis.self
is scope-dependent and it's meant to be used for dynamic inheritance. See statics\nfor a detailed comparison
Ext.define('My.Cat', {\n statics: {\n speciesName: 'Cat' // My.Cat.speciesName = 'Cat'\n },\n\n constructor: function() {\n alert(this.self.speciesName); // dependent on 'this'\n },\n\n clone: function() {\n return new this.self();\n }\n});\n\n\nExt.define('My.SnowLeopard', {\n extend: 'My.Cat',\n statics: {\n speciesName: 'Snow Leopard' // My.SnowLeopard.speciesName = 'Snow Leopard'\n }\n});\n\nvar cat = new My.Cat(); // alerts 'Cat'\nvar snowLeopard = new My.SnowLeopard(); // alerts 'Snow Leopard'\n\nvar clone = snowLeopard.clone();\nalert(Ext.getClassName(clone)); // alerts 'My.SnowLeopard'\n
\nCall the original method that was previously overridden with override
\n\nExt.define('My.Cat', {\n constructor: function() {\n alert(\"I'm a cat!\");\n }\n});\n\nMy.Cat.override({\n constructor: function() {\n alert(\"I'm going to be a cat!\");\n\n this.callOverridden();\n\n alert(\"Meeeeoooowwww\");\n }\n});\n\nvar kitty = new My.Cat(); // alerts \"I'm going to be a cat!\"\n // alerts \"I'm a cat!\"\n // alerts \"Meeeeoooowwww\"\n
\n This method has been deprecated
\nas of 4.1. Use callParent instead.
\n\nThe arguments, either an array or the arguments
object\nfrom the current method, for example: this.callOverridden(arguments)
Returns the result of calling the overridden method
\nCall the \"parent\" method of the current method. That is the method previously\noverridden by derivation or by an override (see Ext.define).
\n\n Ext.define('My.Base', {\n constructor: function (x) {\n this.x = x;\n },\n\n statics: {\n method: function (x) {\n return x;\n }\n }\n });\n\n Ext.define('My.Derived', {\n extend: 'My.Base',\n\n constructor: function () {\n this.callParent([21]);\n }\n });\n\n var obj = new My.Derived();\n\n alert(obj.x); // alerts 21\n
\n\nThis can be used with an override as follows:
\n\n Ext.define('My.DerivedOverride', {\n override: 'My.Derived',\n\n constructor: function (x) {\n this.callParent([x*2]); // calls original My.Derived constructor\n }\n });\n\n var obj = new My.Derived();\n\n alert(obj.x); // now alerts 42\n
\n\nThis also works with static methods.
\n\n Ext.define('My.Derived2', {\n extend: 'My.Base',\n\n statics: {\n method: function (x) {\n return this.callParent([x*2]); // calls My.Base.method\n }\n }\n });\n\n alert(My.Base.method(10); // alerts 10\n alert(My.Derived2.method(10); // alerts 20\n
\n\nLastly, it also works with overridden static methods.
\n\n Ext.define('My.Derived2Override', {\n override: 'My.Derived2',\n\n statics: {\n method: function (x) {\n return this.callParent([x*2]); // calls My.Derived2.method\n }\n }\n });\n\n alert(My.Derived2.method(10); // now alerts 40\n
\nThe arguments, either an array or the arguments
object\nfrom the current method, for example: this.callParent(arguments)
Returns the result of calling the parent method
\nInitialize configuration for this class. a typical example:
\n\nExt.define('My.awesome.Class', {\n // The default config\n config: {\n name: 'Awesome',\n isAwesome: true\n },\n\n constructor: function(config) {\n this.initConfig(config);\n }\n});\n\nvar awesome = new My.awesome.Class({\n name: 'Super Awesome'\n});\n\nalert(awesome.getName()); // 'Super Awesome'\n
\nthis
\nGet the reference to the class from which this object was instantiated. Note that unlike self,\nthis.statics()
is scope-independent and it always returns the class from which it was called, regardless of what\nthis
points to during run-time
Ext.define('My.Cat', {\n statics: {\n totalCreated: 0,\n speciesName: 'Cat' // My.Cat.speciesName = 'Cat'\n },\n\n constructor: function() {\n var statics = this.statics();\n\n alert(statics.speciesName); // always equals to 'Cat' no matter what 'this' refers to\n // equivalent to: My.Cat.speciesName\n\n alert(this.self.speciesName); // dependent on 'this'\n\n statics.totalCreated++;\n },\n\n clone: function() {\n var cloned = new this.self; // dependent on 'this'\n\n cloned.groupName = this.statics().speciesName; // equivalent to: My.Cat.speciesName\n\n return cloned;\n }\n});\n\n\nExt.define('My.SnowLeopard', {\n extend: 'My.Cat',\n\n statics: {\n speciesName: 'Snow Leopard' // My.SnowLeopard.speciesName = 'Snow Leopard'\n },\n\n constructor: function() {\n this.callParent();\n }\n});\n\nvar cat = new My.Cat(); // alerts 'Cat', then alerts 'Cat'\n\nvar snowLeopard = new My.SnowLeopard(); // alerts 'Cat', then alerts 'Snow Leopard'\n\nvar clone = snowLeopard.clone();\nalert(Ext.getClassName(clone)); // alerts 'My.SnowLeopard'\nalert(clone.groupName); // alerts 'Cat'\n\nalert(My.Cat.totalCreated); // alerts 3\n
\nAdd methods / properties to the prototype of this class.
\n\nExt.define('My.awesome.Cat', {\n constructor: function() {\n ...\n }\n});\n\n My.awesome.Cat.addMembers({\n meow: function() {\n alert('Meowww...');\n }\n });\n\n var kitty = new My.awesome.Cat;\n kitty.meow();\n
\nAdd / override static properties of this class.
\n\nExt.define('My.cool.Class', {\n ...\n});\n\nMy.cool.Class.addStatics({\n someProperty: 'someValue', // My.cool.Class.someProperty = 'someValue'\n method1: function() { ... }, // My.cool.Class.method1 = function() { ... };\n method2: function() { ... } // My.cool.Class.method2 = function() { ... };\n});\n
\nthis
\nBorrow another class' members to the prototype of this class.
\n\nExt.define('Bank', {\n money: '$$$',\n printMoney: function() {\n alert('$$$$$$$');\n }\n});\n\nExt.define('Thief', {\n ...\n});\n\nThief.borrow(Bank, ['money', 'printMoney']);\n\nvar steve = new Thief();\n\nalert(steve.money); // alerts '$$$'\nsteve.printMoney(); // alerts '$$$$$$$'\n
\nThe class to borrow members from
\nThe names of the members to borrow
\nthis
\nCreate a new instance of this Class.
\n\nExt.define('My.cool.Class', {\n ...\n});\n\nMy.cool.Class.create({\n someConfig: true\n});\n
\n\nAll parameters are passed to the constructor of the class.
\nthe created instance.
\nCreate aliases for existing prototype methods. Example:
\n\nExt.define('My.cool.Class', {\n method1: function() { ... },\n method2: function() { ... }\n});\n\nvar test = new My.cool.Class();\n\nMy.cool.Class.createAlias({\n method3: 'method1',\n method4: 'method2'\n});\n\ntest.method3(); // test.method1()\n\nMy.cool.Class.createAlias('method5', 'method3');\n\ntest.method5(); // test.method3() -> test.method1()\n
\nThe new method name, or an object to set multiple aliases. See\nflexSetter
\nThe original method name
\nGet the current class' name in string format.
\n\nExt.define('My.cool.Class', {\n constructor: function() {\n alert(this.self.getName()); // alerts 'My.cool.Class'\n }\n});\n\nMy.cool.Class.getName(); // 'My.cool.Class'\n
\nclassName
\nAdds members to class.
\nThis method has been deprecated since 4.1
\nUse addMembers instead.
\n\nOverride members of this class. Overridden methods can be invoked via\ncallParent.
\n\nExt.define('My.Cat', {\n constructor: function() {\n alert(\"I'm a cat!\");\n }\n});\n\nMy.Cat.override({\n constructor: function() {\n alert(\"I'm going to be a cat!\");\n\n this.callParent(arguments);\n\n alert(\"Meeeeoooowwww\");\n }\n});\n\nvar kitty = new My.Cat(); // alerts \"I'm going to be a cat!\"\n // alerts \"I'm a cat!\"\n // alerts \"Meeeeoooowwww\"\n
\n\nAs of 4.1, direct use of this method is deprecated. Use Ext.define\ninstead:
\n\nExt.define('My.CatOverride', {\n override: 'My.Cat',\n constructor: function() {\n alert(\"I'm going to be a cat!\");\n\n this.callParent(arguments);\n\n alert(\"Meeeeoooowwww\");\n }\n});\n
\n\nThe above accomplishes the same result but can be managed by the Ext.Loader\nwhich can properly order the override and its target class and the build process\ncan determine whether the override is needed based on the required state of the\ntarget class (My.Cat).
\nThis method has been deprecated since 4.1.0
\nUse Ext.define instead
\n\nThe properties to add to this class. This should be\nspecified as an object literal containing one or more properties.
\nthis class
\n