webismymind / editablegrid

EditableGrid is an open source Javascript library aimed at turning HTML tables into advanced editable components. It focuses on simplicity: only a few lines of code are required to get your first table up and running.
http://www.editablegrid.net
Other
795 stars 272 forks source link

Any way to change european settings like date and thousands separator? #163

Open GitCarrera opened 7 years ago

GitCarrera commented 7 years ago

I am using the code from the mysql-php example and cant seem to be able to get comma for thousand separators and whenever i try the date and date functions, it displays as day-month instead of month-day-year as I would prefer.

Thanks.

MSIH commented 7 years ago

I have not tested but changlog and code says you can do this. order is important

datatype(unit, precision, decimal_point, thousands_separator, unit_before_number[, nanSymbol])

this.load({ metadata: [ { name: "name", datatype: "double(unit, precision, decimal_point, thousands_separator, unit_before_number)", editable: true },


EditableGrid.prototype.parseColumnType = function(column)
 {  // reset
    column.unit = null;
    column.precision = -1;
    column.decimal_point = ',';
    column.thousands_separator = '.';
    column.unit_before_number = false;
    column.nansymbol = '';
``` // extract precision, unit and number format from type if 6 given
    if (column.datatype.match(/(.*)\((.*),(.*),(.*),(.*),(.*),(.*)\)$/)) {
        column.datatype = RegExp.$1;
        column.unit = RegExp.$2;
        column.precision = parseInt(RegExp.$3);
        column.decimal_point = RegExp.$4;
        column.thousands_separator = RegExp.$5;
        column.unit_before_number = RegExp.$6;
        column.nansymbol = RegExp.$7;

        // trim should be done after fetching RegExp matches beacuse it itself uses a RegExp and causes interferences!
        column.unit = column.unit.trim();
        column.decimal_point = column.decimal_point.trim();
        column.thousands_separator = column.thousands_separator.trim();
        column.unit_before_number = column.unit_before_number.trim() == '1';
        column.nansymbol = column.nansymbol.trim();
    }

    // extract precision, unit and number format from type if 5 given
    else if (column.datatype.match(/(.*)\((.*),(.*),(.*),(.*),(.*)\)$/)) {
        column.datatype = RegExp.$1;
        column.unit = RegExp.$2;
        column.precision = parseInt(RegExp.$3);
        column.decimal_point = RegExp.$4;
        column.thousands_separator = RegExp.$5;
        column.unit_before_number = RegExp.$6;

        // trim should be done after fetching RegExp matches beacuse it itself uses a RegExp and causes interferences!
        column.unit = column.unit.trim();
        column.decimal_point = column.decimal_point.trim();
        column.thousands_separator = column.thousands_separator.trim();
        column.unit_before_number = column.unit_before_number.trim() == '1';
    }
`