+++ /dev/null
-/*\r
- * Ext JS Library 2.2.1\r
- * Copyright(c) 2006-2009, Ext JS, LLC.\r
- * licensing@extjs.com\r
- * \r
- * http://extjs.com/license\r
- */\r
-\r
-/**\r
- * @class Ext.data.Field\r
- * <p>This class encpasulates the field definition information specified in the field definition objects\r
- * passed to {@link Ext.data.Record#create}.</p>\r
- * <p>Developers do not need to instantiate this class. Instances are created by {@link Ext.data.Record.create}\r
- * and cached in the {@link Ext.data.Record#fields fields} property of the created Record constructor's <b>prototype.</b></p>\r
-*/\r
-Ext.data.Field = function(config){\r
- if(typeof config == "string"){\r
- config = {name: config};\r
- }\r
- Ext.apply(this, config);\r
- \r
- if(!this.type){\r
- this.type = "auto";\r
- }\r
- \r
- var st = Ext.data.SortTypes;\r
- // named sortTypes are supported, here we look them up\r
- if(typeof this.sortType == "string"){\r
- this.sortType = st[this.sortType];\r
- }\r
- \r
- // set default sortType for strings and dates\r
- if(!this.sortType){\r
- switch(this.type){\r
- case "string":\r
- this.sortType = st.asUCString;\r
- break;\r
- case "date":\r
- this.sortType = st.asDate;\r
- break;\r
- default:\r
- this.sortType = st.none;\r
- }\r
- }\r
-\r
- // define once\r
- var stripRe = /[\$,%]/g;\r
-\r
- // prebuilt conversion function for this field, instead of\r
- // switching every time we're reading a value\r
- if(!this.convert){\r
- var cv, dateFormat = this.dateFormat;\r
- switch(this.type){\r
- case "":\r
- case "auto":\r
- case undefined:\r
- cv = function(v){ return v; };\r
- break;\r
- case "string":\r
- cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };\r
- break;\r
- case "int":\r
- cv = function(v){\r
- return v !== undefined && v !== null && v !== '' ?\r
- parseInt(String(v).replace(stripRe, ""), 10) : '';\r
- };\r
- break;\r
- case "float":\r
- cv = function(v){\r
- return v !== undefined && v !== null && v !== '' ?\r
- parseFloat(String(v).replace(stripRe, ""), 10) : ''; \r
- };\r
- break;\r
- case "bool":\r
- case "boolean":\r
- cv = function(v){ return v === true || v === "true" || v == 1; };\r
- break;\r
- case "date":\r
- cv = function(v){\r
- if(!v){\r
- return '';\r
- }\r
- if(Ext.isDate(v)){\r
- return v;\r
- }\r
- if(dateFormat){\r
- if(dateFormat == "timestamp"){\r
- return new Date(v*1000);\r
- }\r
- if(dateFormat == "time"){\r
- return new Date(parseInt(v, 10));\r
- }\r
- return Date.parseDate(v, dateFormat);\r
- }\r
- var parsed = Date.parse(v);\r
- return parsed ? new Date(parsed) : null;\r
- };\r
- break;\r
- \r
- }\r
- this.convert = cv;\r
- }\r
-};\r
-\r
-Ext.data.Field.prototype = {\r
- /**\r
- * @cfg {String} name\r
- * The name by which the field is referenced within the Record. This is referenced by,\r
- * for example, the <em>dataIndex</em> property in column definition objects passed to {@link Ext.grid.ColumnModel}\r
- */\r
- /**\r
- * @cfg {String} type\r
- * (Optional) The data type for conversion to displayable value. Possible values are\r
- * <ul><li>auto (Default, implies no conversion)</li>\r
- * <li>string</li>\r
- * <li>int</li>\r
- * <li>float</li>\r
- * <li>boolean</li>\r
- * <li>date</li></ul>\r
- */\r
- /**\r
- * @cfg {Function} convert\r
- * (Optional) A function which converts the value provided by the Reader into an object that will be stored\r
- * in the Record. It is passed the following parameters:<ul>\r
- * <li><b>v</b> : Mixed<div class="sub-desc">The data value as read by the Reader.</div></li>\r
- * <li><b>rec</b> : Mixed<div class="sub-desc">The data object containing the row as read by the Reader.\r
- * Depending on Reader type, this could be an Array, an object, or an XML element.</div></li>\r
- * </ul>\r
- */\r
- /**\r
- * @cfg {String} dateFormat\r
- * (Optional) A format string for the {@link Date#parseDate Date.parseDate} function, or "timestamp" if the\r
- * value provided by the Reader is a UNIX timestamp, or "time" if the value provided by the Reader is a \r
- * javascript millisecond timestamp.\r
- */\r
- dateFormat: null,\r
- /**\r
- * @cfg {Mixed} defaultValue\r
- * (Optional) The default value used <b>when a Record is being created by a\r
- * {@link Ext.data.Reader Reader}</b> when the item referenced by the <b><tt>mapping</tt></b> does not exist in the data object\r
- * (i.e. undefined). (defaults to "")\r
- */\r
- defaultValue: "",\r
- /**\r
- * @cfg {String} mapping\r
- * (Optional) A path specification for use by the {@link Ext.data.Reader} implementation\r
- * that is creating the Record to access the data value from the data object. If an {@link Ext.data.JsonReader}\r
- * is being used, then this is a string containing the javascript expression to reference the data relative to\r
- * the Record item's root. If an {@link Ext.data.XmlReader} is being used, this is an {@link Ext.DomQuery} path\r
- * to the data item relative to the Record element. If the mapping expression is the same as the field name,\r
- * this may be omitted.\r
- */\r
- mapping: null,\r
- /**\r
- * @cfg {Function} sortType\r
- * (Optional) A function which converts a Field's value to a comparable value in order to ensure correct\r
- * sort ordering. Predefined functions are provided in {@link Ext.data.SortTypes}\r
- */\r
- sortType : null,\r
- /**\r
- * @cfg {String} sortDir\r
- * (Optional) Initial direction to sort. "ASC" or "DESC"\r
- */\r
- sortDir : "ASC"\r
-};
\ No newline at end of file