EditableGrid Data Types: double

I am using the editablegrid library to edit the table, so I can later edit and update the database that I am pulling data from. I am having some problems with metadata header in jsp. I have:

<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 very well, however the PRICE column that is displayed looks strange, it uses a comma instead of a full loop and vice versa. For example:

1.5 (one and a half) will display as "1.5", 1500 (one thousand five hundred) will display as "1.500"

Does anyone know how to change this?

+3


source to share


2 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 specified "$" because I want a dollar sign in front of the number. "2" because I want two decimal places. "period" because I want a period as a decimal separator, a "comma" for a thousand separator and 1 because I want the dollar sign to come before the number, not after.

+5


source


Also a good and concise explanation:

using:

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

      

Example:



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

      

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

Discussion link: https://github.com/webismymind/editablegrid/issues/51

0


source







All Articles