Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EditableGrid datatypes: double

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?

like image 869
Twinhelix Avatar asked Mar 02 '26 09:03

Twinhelix


1 Answers

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.

like image 56
davidwebster48 Avatar answered Mar 04 '26 16:03

davidwebster48



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!