Error on "All Column Search" When Using calculated column

QuestionsError on "All Column Search" When Using calculated column
Tony Wolsey asked 1 year ago

Hello Abu

I am receiving and error when I use the “All Column Search” and have a calculated column in the MySQL query. It states that it cannot find the calculated column.

“Couldn’t execute query. Unknown column ‘est.quantity * est.administration’ in ‘where clause’…”

$g->select_command = “SELECT
est.id,
est.projectnumberest,
est.tasks,
est.quantity,
est.factor,
est.administration,

t.taskduration,

est.quantity * est.administration as totaladmin

FROM tblestimate est

INNER JOIN tbltask t ON est.tasks = t.task

where est.projectnumberest = ‘$PROJECTNUMBERVAR’

“;

$col = array();
$col[“title”] = “Admin”;
$col[“name”] = “administration”;
$col[“width”] = “100”;
$col[“editable”] = true;
$col[“search”] = true;
$col[“export”] = true;
$col[“align”] = “center”;
//$col[“edittype”] = “lookup”;
//$col[“frozen”] = true;
//$col[“editoptions”] = array(“table”=>”tblpid”, “id”=>”pid”, “label”=>”PID”);
//$col[“show”] = array(“edit”=>false);
$cols[] = $col;

$col = array(); //est.quantity * est.administration as totaladmin,
$col[“title”] = “AdminTotalHrs”;
$col[“name”] = “totaladmin”;
$col[“dbname”] = “est.quantity * est.administration”;
$col[“width”] = “100”;
$col[“editable”] = false;
$col[“search”] = true;
$col[“export”] = true;
$col[“align”] = “center”;
$col[“formatter”] = “number”;
$col[“formatoptions”] = array(“thousandsSeparator” => “,”,
“decimalSeparator” => “.”,
“decimalPlaces” => 2);
//$col[“edittype”] = “lookup”;
//$col[“frozen”] = true;
//$col[“editoptions”] = array(“table”=>”tblpid”, “id”=>”pid”, “label”=>”PID”);
//$col[“show”] = array(“edit”=>false);
$cols[] = $col;

 

thanks

Tony

2 Answers
Abu Ghufran Staff answered 1 year ago

Please share complete error message which include incorrect sql query (…)

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Tony Wolsey answered 1 year ago

I sorted it out. I had to place the calculated column contents within brackets

 

$col = array(); //est.quantity * est.administration as totaladmin,
$col[“title”] = “AdminTotalHrs”;
$col[“name”] = “totaladmin”;
$col[“dbname”] = “(est.quantity * est.administration)”;
$col[“width”] = “100”;
$col[“editable”] = false;
$col[“search”] = true;
$col[“export”] = true;
$col[“align”] = “center”;
$col[“formatter”] = “number”;
$col[“formatoptions”] = array(“thousandsSeparator” => “,”,
“decimalSeparator” => “.”,
“decimalPlaces” => 2);
//$col[“edittype”] = “lookup”;
//$col[“frozen”] = true;
//$col[“editoptions”] = array(“table”=>”tblpid”, “id”=>”pid”, “label”=>”PID”);
//$col[“show”] = array(“edit”=>false);
$cols[] = $col;

 

thanks

Tony

Your Answer

18 + 20 =

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?