textlist: make format a property of a column

This commit is contained in:
rlx 2011-01-06 06:10:46 +00:00
parent 9905848bb6
commit 07dd8d0190
2 changed files with 18 additions and 5 deletions

View file

@ -1185,6 +1185,10 @@ Format functions
================================================================================ ================================================================================
*/ */
Ox.formatCurrency = function(num, str, dec) {
return str + formatNumber(num, dec);
};
Ox.formatDate = function() { Ox.formatDate = function() {
/* /*
See http://developer.apple.com/documentation/Darwin/Reference/ManPages/man3/strftime.3.html See http://developer.apple.com/documentation/Darwin/Reference/ManPages/man3/strftime.3.html

View file

@ -6049,6 +6049,7 @@ requires
.defaults({ .defaults({
centered: false, centered: false,
construct: function() {}, construct: function() {},
format: [],
itemHeight: 16, itemHeight: 16,
itemWidth: 16, itemWidth: 16,
keys: [], keys: [],
@ -6948,8 +6949,10 @@ requires
if (Ox.isArray(v)) { if (Ox.isArray(v)) {
self.data[k] = v.join(', '); self.data[k] = v.join(', ');
} else if (format) { } else if (format) {
self.data[k] = Ox['format' + Ox.toTitleCase(format.type)] self.data[k] = Ox.isObject(format) ?
.apply(this, $.merge([v], format.args)); Ox['format' + Ox.toTitleCase(format.type)]
.apply(this, $.merge([v], format.args)) :
format(v);
} }
}); });
@ -6982,7 +6985,6 @@ requires
columnsResizable: false, columnsResizable: false,
columnsVisible: false, columnsVisible: false,
columnWidth: [40, 800], columnWidth: [40, 800],
format: [],
id: '', id: '',
max: -1, max: -1,
min: 0, min: 0,
@ -7023,6 +7025,13 @@ requires
pageHeight: self.options.pageLength * self.itemHeight 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 // Head
if (self.options.columnsVisible) { if (self.options.columnsVisible) {
@ -7059,11 +7068,11 @@ requires
that.$body = new Ox.List({ that.$body = new Ox.List({
construct: constructItem, construct: constructItem,
format: self.options.format,
id: self.options.id, id: self.options.id,
itemHeight: 16, itemHeight: 16,
itemWidth: getItemWidth(), itemWidth: getItemWidth(),
keys: $.map(self.visibleColumns, function(v, i) { format: self.format,
keys: $.map(self.visibleColumns, function(v) {
return v.id; return v.id;
}), }),
max: self.options.max, max: self.options.max,