3

I'm using the editablegrid library to make a table editable so I can later edit and update the database I'm pulling data from. I'm having some issues with the metadata header in the jsp. I've got:

<script src="js/editablegrid-2.0.1.js"></script>
<script>
    window.onload = function() {
        editableGrid = new EditableGrid("grid");

        // we build and load the metadata in Javascript
        editableGrid.load({
            metadata : [ {
                name : "ID",
                datatype : "string",
                editable : false
            }, {
                name : "DATE",
                datatype : "date",
                editable : false
            }, {
                name : "PRICE",
                datatype : "double (m, 10)",
                editable : true
            } ]
        });

        editableGrid.attachToHTMLTable('Grid');
        editableGrid.renderGrid();
    };
</script>

This all works quite nicely, however the PRICE column that is displayed is kinda weird, it uses a comma instead of a fullstop and vice versa. So for example:

1.5 (one and a half) will be displayed as "1,5" 1,500 (one thousand five hundred) will be displayed as "1.500"

Does anyone know how to change this?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Twinhelix
  • 165
  • 2
  • 14

2 Answers2

5

The following worked for me.

{ name: "Price", datatype: "double($,2,dot,comma,1)", editable: true },

You can find out the format of the datatype parameter by reading the source.

In this case I have specified "$" because I want a dollar sign before the number. "2" because I want two decimal places. "dot" because I want a dot as the decimal separator, "comma" for the thousands separator, and 1 because I want the dollar sign to come before the number rather than after.

davidwebster48
  • 604
  • 1
  • 8
  • 21
0

Also a good and short explanation:

usage:

double(<unit>, <precision>, <decimal_point>, <thousands_separator>, 
       <show_unit_before_number>, <nansymbol>)

example:

double(m³, 2, dot, comma, 0, n/a)

Link to Code: https://github.com/webismymind/editablegrid/blob/master/editablegrid.js#L698

Link to Discussion: https://github.com/webismymind/editablegrid/issues/51

webMac
  • 185
  • 1
  • 2
  • 11