From cd5fcb9793bd4a9cbf689c2aa2489a17a0a05db2 Mon Sep 17 00:00:00 2001 From: Dhananjay Vasa Date: Mon, 8 Aug 2016 19:35:55 -0400 Subject: [PATCH 1/3] Implemented some of the properties for EditableGrid for json parsing. --- editablegrid.js | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/editablegrid.js b/editablegrid.js index 1c3de8d..d6b3a7e 100644 --- a/editablegrid.js +++ b/editablegrid.js @@ -20,8 +20,8 @@ function Column(config) unit: null, precision: -1, // means that all decimals are displayed nansymbol: '', - decimal_point: ',', - thousands_separator: '.', + decimal_point: ',', // can also be specified by comma or dot + thousands_separator: '.', // can also be specified by comma or dot unit_before_number: false, bar: true, // is the column to be displayed in a bar chart ? relevant only for numerical columns hidden: false, // should the column be hidden by default @@ -37,7 +37,7 @@ function Column(config) }; // override default properties with the ones given - for (var p in props) this[p] = (typeof config == 'undefined' || typeof config[p] == 'undefined') ? props[p] : config[p]; + for (var p in props) this[p] = (typeof config == 'undefined' || typeof config[p] == 'undefined' || config[p] == null) ? props[p] : config[p]; } Column.prototype.getOptionValuesForRender = function(rowIndex) { @@ -602,10 +602,16 @@ EditableGrid.prototype.processJSON = function(jsonData) this.columns.push(new Column({ name: columndata.name, label: (columndata.label ? columndata.label : columndata.name), - datatype: (columndata.datatype ? columndata.datatype : "string"), editable: (columndata.editable ? true : false), - bar: (typeof columndata.bar == 'undefined' ? true : (columndata.bar || false)), + renderable: columndata.renderable, + datatype: (columndata.datatype ? columndata.datatype : "string"), + decimal_point: columndata.decimal_point, + unit: columndata.unit, + unit_before_number: columndata.unit_before_number, + thousands_separator: columndata.thousands_separator, + bar: (typeof columndata.bar == 'undefined' ? true : (columndata.bar || false)), hidden: (typeof columndata.hidden == 'undefined' ? false : (columndata.hidden ? true : false)), + nansymbol: columndata.nansymbol, optionValuesForRender: optionValuesForRender, optionValues: optionValues })); @@ -697,13 +703,13 @@ EditableGrid.prototype.processColumns = function() 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 = ''; + //// 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(/(.*)\((.*),(.*),(.*),(.*),(.*),(.*)\)$/)) { From d27b19d8d1e44c8d8298e3901b0000a34cae52db Mon Sep 17 00:00:00 2001 From: Dhananjay Vasa Date: Mon, 8 Aug 2016 19:36:38 -0400 Subject: [PATCH 2/3] Based on the rest of the codebase, nansymbol should be all lowercase to avoid ambiguity. --- CHANGELOG.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index c4d34fa..9d07401 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -38,7 +38,7 @@ MISC.: * Function sort() is called by renderGrid only if there is a currently defined sorting order (to avoid a double render) but the expected callback tableSorted is still called * Added column attributes: decimal_point, thousands_separator, unit_before_number. All have a default value and can be overridden in the XML column type declaration, as follows: - datatype(unit, precision, decimal_point, thousands_separator, unit_before_number[, nanSymbol]) + datatype(unit, precision, decimal_point, thousands_separator, unit_before_number[, nansymbol]) e.g. double(€, 2, comma, dot, 0, n/a) * Lots of other bugfixes and minor improvements! From 55945bc1826e03871e70dc3d2bc73a5b4ad13041 Mon Sep 17 00:00:00 2001 From: Dhananjay Vasa Date: Mon, 8 Aug 2016 19:41:48 -0400 Subject: [PATCH 3/3] Whitespace and removed code which overrode defaults set in constructor. --- editablegrid.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/editablegrid.js b/editablegrid.js index d6b3a7e..5e68236 100644 --- a/editablegrid.js +++ b/editablegrid.js @@ -605,13 +605,13 @@ EditableGrid.prototype.processJSON = function(jsonData) editable: (columndata.editable ? true : false), renderable: columndata.renderable, datatype: (columndata.datatype ? columndata.datatype : "string"), - decimal_point: columndata.decimal_point, + decimal_point: columndata.decimal_point, unit: columndata.unit, unit_before_number: columndata.unit_before_number, thousands_separator: columndata.thousands_separator, bar: (typeof columndata.bar == 'undefined' ? true : (columndata.bar || false)), hidden: (typeof columndata.hidden == 'undefined' ? false : (columndata.hidden ? true : false)), - nansymbol: columndata.nansymbol, + nansymbol: columndata.nansymbol, optionValuesForRender: optionValuesForRender, optionValues: optionValues })); @@ -703,14 +703,6 @@ EditableGrid.prototype.processColumns = function() 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;