sum issue when formatter is used

Questionssum issue when formatter is used
David asked 10 years ago

I'v buy yesterday the dev version of this amazing grid , all seems to working fine except one little thing.

if i use currency formatter on a column, sum does not work, returning NaN.

if i remove formatter the sum work.

any idea ?

$col = array();
$col["title"] = "Total"; // caption of column
$col["name"] = "amt"; // grid column name, same as db field or alias from sql
$col["width"] = "2"; // width on grid
$col["formatter"] = "currency";
$col["formatoptions"] = " can't post , cause invalid character ?"

var opts = {
'loadComplete': function () {
var grid2 = $("#list2");
grid2.jqGrid('footerData','set', {amt: 'Total: '+sum});
},

};

5 Answers
Abu Ghufran answered 10 years ago

Hello,

Just remove string 'Total', and it will format $ string.

grid2.jqGrid('footerData','set', {amt: sum});

David answered 10 years ago

Hi Abu,

Thanks,it almost works but i must disable formatter to make it work , if i keep formatoptions instead of NaN i have 0,00

with $col["formatoptions"] disabled it write correct sum but without suffix 'euro' and without right decimal seperator on the footer and column.

here is my formatoption now i can post code !

array("prefix" => '',
"suffix" => ' €',
"thousandsSeparator" => ",",
"decimalSeparator" => ".",
"decimalPlaces" => '2');

grid2.jqGrid('footerData','set', {amt:sum});

Thanks for your good work

Abu Ghufran answered 10 years ago

I checked that there is some issue with using euro sign.

You can use custom formatter in this case.

$col["formatter"] = "function(v){ return v+' €'; }";
$col["unformat"] = "function(v){ return parseFloat(v); }";

Abu Ghufran answered 10 years ago

Also check this link for using custom formatter.
http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_formatter

David answered 10 years ago

Thanks for workaround Abu

Your Answer

8 + 10 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?