123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- /*
- * Ext JS Library 2.0 Copyright(c) 2006-2007, Ext JS, LLC. licensing@extjs.com
- *
- * http://extjs.com/license
- */
- Ext.data.Field = function(D) {
- if (typeof D == "string") {
- D = {
- name : D
- }
- }
- Ext.apply(this, D);
- if (!this.type) {
- this.type = "auto"
- }
- var C = Ext.data.SortTypes;
- if (typeof this.sortType == "string") {
- this.sortType = C[this.sortType]
- }
- if (!this.sortType) {
- switch (this.type) {
- case "string" :
- this.sortType = C.asUCString;
- break;
- case "date" :
- this.sortType = C.asDate;
- break;
- default :
- this.sortType = C.none
- }
- }
- var E = /[\$,%]/g;
- if (!this.convert) {
- var B, A = this.dateFormat;
- switch (this.type) {
- case "" :
- case "auto" :
- case undefined :
- B = function(F) {
- return F
- };
- break;
- case "string" :
- B = function(F) {
- return (F === undefined || F === null) ? "" : String(F)
- };
- break;
- case "int" :
- B = function(F) {
- return F !== undefined && F !== null && F !== ""
- ? parseInt(String(F).replace(E, ""), 10)
- : ""
- };
- break;
- case "float" :
- B = function(F) {
- return F !== undefined && F !== null && F !== ""
- ? parseFloat(String(F).replace(E, ""), 10)
- : ""
- };
- break;
- case "bool" :
- case "boolean" :
- B = function(F) {
- return F === true || F === "true" || F == 1
- };
- break;
- case "date" :
- B = function(G) {
- if (!G) {
- return ""
- }
- if (G instanceof Date) {
- return G
- }
- if (A) {
- if (A == "timestamp") {
- return new Date(G * 1000)
- }
- if (A == "time") {
- return new Date(parseInt(G, 10))
- }
- return Date.parseDate(G, A)
- }
- var F = Date.parse(G);
- return F ? new Date(F) : null
- };
- break
- }
- this.convert = B
- }
- };
- Ext.data.Field.prototype = {
- dateFormat : null,
- defaultValue : "",
- mapping : null,
- sortType : null,
- sortDir : "ASC"
- };
|