FYI, there is a central place where all the formatting goes through:

    http://static.simile.mit.edu/exhibit/api-2.0/scripts/ui/formatter.js

(provided that the value types of the properties are declared 
appropriately). So, to get the commas into the numbers, you could 
override this function:

    Exhibit.Formatter._NumberFormatter.prototype.formatText = 
function(value) {
        if (this._decimalDigits == -1) {
            return value.toString();
        } else {
            return new Number(value).toFixed(this._decimalDigits);
        }
    };

In future fixes that formatting option can be built-in. More to put on 
the to-do list! :-)

David

Neil Ireson wrote:
> Hi Mummi,
>
> There's nothing in HTML/CSS so you'd have to write your own javascript 
> function to add the commas, a la...
>
> function addCommas(nStr)
> {
>       nStr += '';
>       x = nStr.split('.');
>       x1 = x[0];
>       x2 = x.length > 1 ? '.' + x[1] : '';
>       var rgx = /(\d+)(\d{3})/;
>       while (rgx.test(x1)) {
>               x1 = x1.replace(rgx, '$1' + ',' + '$2');
>       }
>       return x1 + x2;
> }
>   
> (NB not my code but stolen from somewhere on the web)
>
> Hope that helps
>
> N
>
>
> > To: [email protected]
> > Subject: Number formats in Exhibit
> > Date: Thu, 24 Jan 2008 10:45:13 +0000
> > From: [EMAIL PROTECTED]
> >
> > Quick question about numbers in Exhibit: I have some fields in my
> > JSON data with numbers in them and would like to both sort & filter
> > on them like numbers, and also format them with thousand-separators
> > (e.g. 100,000) for readability. I can achieve the latter by
> > preformatting the numbers before creating my JSON, but then they'll
> > be treated as text by Exhibit I presume. Is there a CSS style for
> > formatting numbers in this fashion, or something built into Exhibit?
> >
> >
> > Mummi
> >
> > -----------------------------------------------------------
> > Gudmundur A. Thorisson, PhD student, Brookes lab
> > E-mail: [EMAIL PROTECTED]
> > Location: Adrian building, room G11
> >
> >
> > _______________________________________________
> > General mailing list
> > [email protected]
> > http://simile.mit.edu/mailman/listinfo/general
>
> ------------------------------------------------------------------------
> Think you know your TV, music and film? Try Search Charades! 
> <https://www.searchcharades.com>
> ------------------------------------------------------------------------
>
> _______________________________________________
> General mailing list
> [email protected]
> http://simile.mit.edu/mailman/listinfo/general
>   

_______________________________________________
General mailing list
[email protected]
http://simile.mit.edu/mailman/listinfo/general

Reply via email to