Thanks David - That worked like a treat!
Peter
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of David Huynh
Sent: Tuesday, 18 March 2008 6:43 AM
To: [EMAIL PROTECTED]; General List
Subject: Re: Exhibit: Using Numeric Range Facet for Currency
Peter Frederick wrote:
> Currently it looks like the numeric range facet works if valueType:number
> but now I've had to set a valueType:currency to get it displayed correctly
> the numeric range facet I had no longer works.
>
> Would it be difficult to get this facet type to also work on currency
fields
> (assuming a decimal currency I suppose).
>
It's a bug, but you can overcome this problem temporarily by adding your
own Javascript code after including exhibit-api.js to override the
default implementation:
<script>
Exhibit.Database._Property.prototype._buildRangeIndex = function() {
var getter;
var database = this._database;
var p = this._id;
switch (this.getValueType()) {
case "number":
case "currency":
getter = function(item, f) {
database.getObjects(item, p, null,
null).visit(function(value) {
if (typeof value != "number") {
value = parseFloat(value);
}
if (!isNaN(value)) {
f(value);
}
});
};
break;
case "date":
getter = function(item, f) {
database.getObjects(item, p, null,
null).visit(function(value) {
if (value != null && !(value instanceof Date)) {
value =
SimileAjax.DateTime.parseIso8601DateTime(value);
}
if (value instanceof Date) {
f(value.getTime());
}
});
};
break;
default:
getter = function(item, f) {};
}
this._rangeIndex = new Exhibit.Database._RangeIndex(
this._database.getAllItems(),
getter
);
};
</script>
The default implementation of that function can be found in
http://static.simile.mit.edu/exhibit/api-2.0/scripts/data/database.js
And I just inserted the line
case "currency":
David
_______________________________________________
General mailing list
[email protected]
http://simile.mit.edu/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://simile.mit.edu/mailman/listinfo/general