From 07dd8d0190797e59e7e0be4da6e35c49457c7371 Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Thu, 6 Jan 2011 06:10:46 +0000 Subject: [PATCH] textlist: make format a property of a column --- build/js/ox.js | 4 ++++ build/js/ox.ui.js | 19 ++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/build/js/ox.js b/build/js/ox.js index 405fb151..115c0667 100644 --- a/build/js/ox.js +++ b/build/js/ox.js @@ -1185,6 +1185,10 @@ Format functions ================================================================================ */ +Ox.formatCurrency = function(num, str, dec) { + return str + formatNumber(num, dec); +}; + Ox.formatDate = function() { /* See http://developer.apple.com/documentation/Darwin/Reference/ManPages/man3/strftime.3.html diff --git a/build/js/ox.ui.js b/build/js/ox.ui.js index 8caaba8e..12589308 100644 --- a/build/js/ox.ui.js +++ b/build/js/ox.ui.js @@ -6049,6 +6049,7 @@ requires .defaults({ centered: false, construct: function() {}, + format: [], itemHeight: 16, itemWidth: 16, keys: [], @@ -6948,8 +6949,10 @@ requires if (Ox.isArray(v)) { self.data[k] = v.join(', '); } else if (format) { - self.data[k] = Ox['format' + Ox.toTitleCase(format.type)] - .apply(this, $.merge([v], format.args)); + self.data[k] = Ox.isObject(format) ? + Ox['format' + Ox.toTitleCase(format.type)] + .apply(this, $.merge([v], format.args)) : + format(v); } }); @@ -6982,7 +6985,6 @@ requires columnsResizable: false, columnsVisible: false, columnWidth: [40, 800], - format: [], id: '', max: -1, min: 0, @@ -7023,6 +7025,13 @@ requires pageHeight: self.options.pageLength * self.itemHeight }); + self.format = {}; + self.options.columns.forEach(function(v, i) { + if (v.format) { + self.format[v.id] = v.format; + } + }); + // Head if (self.options.columnsVisible) { @@ -7059,11 +7068,11 @@ requires that.$body = new Ox.List({ construct: constructItem, - format: self.options.format, id: self.options.id, itemHeight: 16, itemWidth: getItemWidth(), - keys: $.map(self.visibleColumns, function(v, i) { + format: self.format, + keys: $.map(self.visibleColumns, function(v) { return v.id; }), max: self.options.max,