can not display field calculated on the fly

Questionscan not display field calculated on the fly
Cedric asked 4 years ago

Hello,

I am trying to display discrency on 2 mass. Value is calculated in the SQL query like this

SELECT
id,
Tank,
Mass,
Mass_sap,
Mass_sap-Mass AS Discrepency2,
CASE
WHEN abs(Mass_sap-Mass) > 1000 THEN CONCAT(\'<font color=red>\’,Mass_sap-Mass,\'</font>\’)
ELSE CONCAT(\'<font color=black>\’,Mass_sap-Mass,\'</font>\’)
END as Discrepency
FROM tank

but the field is always empty..

$col = array();
$col[“title”] = “Discrepency”;
$col[“name”] = “Discrepency”;
$col[“width”] = “30”;
$cols[] = $col;

no matter what I do…

is this a limitation of the grid?

The query works fine on an sql editor or another php grid..

Thanks for your help

Cedric

9 Answers
Abu Ghufran Staff answered 4 years ago

Please refer this demo code, line 100:

https://gist.github.com/gridphp/b37faca7a4173222a5eaeb1ecc7733ef

I removed backslash \ from query and working as expected, tested on mysql.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Cedric answered 4 years ago

What could be the issue then?

I review the code, and have the exact same

What could be preventing the display of Discrepency or Discrepency2 ?

Abu Ghufran Staff answered 4 years ago

If you don’t see the columns on grid, there is possibility that they are hidden due to screen size.

You can turn off responsive:false and recheck.

$opt[“responsive”] = false;
// …
$g->set_options($opt);

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Cedric answered 4 years ago

View post on imgur.com

I can see the column, but it remains empty…

same with responsive disable

Abu Ghufran Staff answered 4 years ago

Please come on google hangouts, i think we need a remote desktop session here.

id: [email protected]

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Abu Ghufran Staff answered 4 years ago

It’s late here, so i’m taking off now. Let me know your feasible time and time zone if you need session.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Cedric answered 4 years ago

Hello Abu,

It was late for me too.

I sent you an hangout invite. Let me know if you have any free time today

Cedric answered 4 years ago

available today?

Your Answer

5 + 0 =

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?