Categories | Question details Back To List | ||
Safari (Webkit) New row cells not empty, nor do they seem to be equal to a blankspace. Need way to determine uninitialized cell. Hello, The problem happens when a new row is added to a grid. In IE cells are initially empty ("") and our audit for that works. In Safari, the cell value passes audits for both empty string ("") and for a blankspace (" "). If you display the value as an alert however, it looks like a single blankspace (" "). When the parseFloat is done, then it fails and yields NaN. We are wondering if there is a generic fix that will correct this in all of our code. Any help that you can provide would be greatly appreciated. Thanks, Jerry This is the original method //calculates total time function sumTotalTime(ind) { var t = 0; var value = 0; for(var i=0;i<mygrid.getRowsNum();i++) { value = mygrid.cells2(i,ind).getValue(); if ((value != '') || (value != ' ')) { t += parseFloat(value); } } return t; } Notes about Value 1. Value passes this check (value != '') 2. Value also passed this additional check (value != ' ') 3. When we did an alert($value$) on value, it looked like a blank space…”$ $”. 4. When the parseFloat is done on value, we get NaN. Answer posted by Support on Feb 03, 2009 02:29 The problem may be caused on initial data source - if it is an XML , and data contains a few whitespaces or new-lines characters, IE will convert them in single whitespace, while Webkit may preserve as is ( it is questionable which behavior is more correct ) In common case , if you have provide really empty cell tag <cell></cell> in xml - it will be equal in both browsers. As fast solution , you can modify your code as for(var i=0;i<mygrid.getRowsNum();i++) { value = parseFloat(mygrid.cells2(i,ind).getValue()); if (!isNaN(value)) t+=value; } Answer posted by Jerry Finegan on Feb 03, 2009 07:33 Thanks for the quick reply. The data from the initial data source is OK. The problem only arises when you add a new row. The error is thrown when checking the value of a cell within that new row to see if data has been entered. In IE, this new cell will have an initial value of an Empty string. In Webkit, it appears to be something else. Thanks again, Jerry
Answer posted by Support on Feb 03, 2009 08:37 Please provide a sample of js command, which used for row adding in problematic case. ( the sample, which adds empty value by addRow js command and get it absolutely the same in all browsers , was sent to your email address ) |