4 * Copyright(c) 2006-2007, Ext JS, LLC.
6 * Originally Released Under LGPL - original licence link has changed is not relivant.
9 * <script type="text/javascript">
13 Roo.data.Field = function(config){
14 if(typeof config == "string"){
15 config = {name: config};
17 Roo.apply(this, config);
23 var st = Roo.data.SortTypes;
24 // named sortTypes are supported, here we look them up
25 if(typeof this.sortType == "string"){
26 this.sortType = st[this.sortType];
29 // set default sortType for strings and dates
33 this.sortType = st.asUCString;
36 this.sortType = st.asDate;
39 this.sortType = st.none;
44 var stripRe = /[\$,%]/g;
46 // prebuilt conversion function for this field, instead of
47 // switching every time we're reading a value
49 var cv, dateFormat = this.dateFormat;
54 cv = function(v){ return v; };
57 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
61 return v !== undefined && v !== null && v !== '' ?
62 parseInt(String(v).replace(stripRe, ""), 10) : '';
67 return v !== undefined && v !== null && v !== '' ?
68 parseFloat(String(v).replace(stripRe, ""), 10) : '';
73 cv = function(v){ return v === true || v === "true" || v == 1; };
80 if(v instanceof Date){
84 if(dateFormat == "timestamp"){
85 return new Date(v*1000);
87 return Date.parseDate(v, dateFormat);
89 var parsed = Date.parse(v);
90 return parsed ? new Date(parsed) : null;
99 Roo.data.Field.prototype = {