Thursday, July 14, 2011

javascript math

So what is 70.18*100 in javascript? It might be surprise you that the result is 7018.00000000001.

And number.toFixed() should fix this nicely.

Another interesting thing about jqGrid. I have a date column that requires a customized format but needs to be sorted as date. I did some research and none of the online solution works (my jqGrid version is 3.6.5). So I download the source, and what's going on is jqGrid parse the date with y,m,d,h,i,s A (as year, month, date, hour, minute, second, AM/PM). So the solution is:

sorttype: 'datetime', datefmt: 'm-d-y h:i:s A' (I am mm-dd-yyyy hh:mm:ss AM/PM format).

No comments: