Two errors

QuestionsTwo errors
Fabio Martins asked 11 years ago

Hi Sir!

Please, I'm having two erros:

1) It is displayed a box with the content below:

{"page":"1","total":5,"records":"467","rows":[
{"id":"282","prn":"","cod_cont":"1.00.00.000000","tipoconta":"S","tipo":"D","desc_cont":"ATIVO"},
{"id":"272","prn":"","cod_cont":"1.01.01.000000","tipoconta":"S","tipo":"D","desc_cont":"CAIXA"},
{"id":"273","prn":"","cod_cont":"1.01.01.000001","tipoconta":"A","tipo":"D","desc_cont":"Caixa Principal"}]}

What is this?

2) In code below, sometimes returns "undefined" and other times returns full value (the correct):

$col = array();
$col["title"] = "Saldo (R$)";
$col["name"] = "saldo";
$col["id"] = "saldo";
$col["align"] = "right";
$col["formatter"] = "function(cellvalue, options, rowObject) { return formatPrice(cellvalue, options, rowObject); }";
$cols[] = $col;

function formatPrice(cellvalue, options, rowObject) {
if (typeof(cellvalue) == "undefined") {
return '0,00';
} else {
return moeda(parseFloat(cellvalue));
}
}

Thank you!

6 Answers
Abu Ghufran answered 11 years ago

1) This is due to some extra white space character, between the call of $g->render(); Please check all include files for ending white space character. Ideally, there must be no output before sent to browser before $g->render().

2) You can debug it by putting alert(cellvalue); for each record, and see which one is producing this error. I cannot exactly tell the reason unless debug it. You can email code+db-dump to regenerate the scenario and check, if not resolved.

Fabio Martins answered 11 years ago

The first error is only on IE 10. On Firefox 25.0 haven't error.
Thank you!

Abu Ghufran answered 11 years ago

Hello,

Can you check what character is it appending before JSON strong.
If you copy (ctrl+c) the alert box, and paste in notepad, it would show you.

Fabio Martins answered 11 years ago

Hi Sir!

First error is solved (I used json_encode($retorno) to manipulate portuguese characters in IE).

Now, I'm going debug second error according to your instructions!

Thank you by your support!

Fábio Martins

Fabio Martins answered 11 years ago

In second error I put alert(cellvalue) and:

A) When returns undefined value, alert(cellvalue) doesn't called.
B) When returns numeric value, alert(cellvalue) is called.

Please, why my JS script doesn't called all times?

Thank you!
Fábio Martins

Abu Ghufran answered 11 years ago

You can try putting "IFNULL(saldo,0) as saldo" in SQL query.
In this way, it will never be null.

Your Answer

8 + 12 =

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?