12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- /*
- * Copyright Scand LLC http://www.scbr.com To use this component please contact
- * info@scbr.com to obtain license
- */
- /*
- * Decimal value (10,000.00) eXcell for dhtmlxGrid (c)Scand LLC 2005
- *
- *
- * The corresponding cell value in XML should be valid number
- *
- * Samples: <cell>123.01</cell> <cell>1234.09356</cell> <cell>12345</cell>
- * <cell>0</cell> <cell>-100</cell>
- */
- function eXcell_dec(cell) {
- this.cell = cell;
- this.grid = this.cell.parentNode.grid;
- // this.edit = function(){}
- this.getValue = function() {
- return parseFloat(this.cell.innerHTML.replace(/,/g, ""));
- }
- this.setValue = function(val) {
- var format = "0,000.00";
- if (val == "0") {
- this.cell.innerHTML = format.replace(/.*(0\.[0]+)/, "$1");
- return;
- }
- var z = format.substr(format.indexOf(".") + 1).length
- val = Math.round(val * Math.pow(10, z)).toString();
- var out = "";
- var cnt = 0;
- var fl = false;
- for (var i = val.length - 1; i >= 0; i--) {
- cnt++;
- out = val.charAt(i) + out;
- if (!fl && cnt == z) {
- out = "." + out;
- cnt = 0;
- fl = true;
- }
- if (fl && cnt == 3 && i != 0 && val.charAt(i - 1) != '-') {
- out = "," + out;
- cnt = 0;
- }
- }
- this.cell.innerHTML = out;
- }
- }
- eXcell_dec.prototype = new eXcell_ed;
|