I have a column named problem_status and I am storing 0 and 1 value in it. I am displaying it in the grid as
if($_SESSION['userLevel'] != 'unit') {
$col = array();
$col["title"] = "Problem Status";
$col["name"] = "problem_status";
$col["condition"] = array('$row["problem_status"] == 1', 'Open', 'Closed');
$col["width"] = "110";
$col["link"] = "problem_report_sheet.php?form=problem_report&id={id}";
$col["linkoptions"] = "target='_blank' style='text-decoration: underline'";
$cols[] = $col;
} else {
$col = array();
$col["title"] = "Problem Status";
$col["name"] = "problem_status";
$open = "<a target='_blank' href='problem_report_sheet.php?form=problem_report&id={id}' style='text-decoration:underline;'>Open</a>";
$close = 'Closed';
$col["condition"] = array('$row["problem_status"] == 1', $open, $close);
$col["width"] = "110";
$cols[] = $col;
}
I have 1 and 0 value in the database but I am displaying as Open and Closed in the grid. Can you please guide why Search / Filter at the column top is not working ?
For search operation, in background it uses WHERE condition of sql query. So we must have equivalent database sql for your condition.
In this case, you can set, e.g.:
$col["dbname"] = "IF(problem_status==1,'Open','Closed')";
Now your sql query will become:
SELECT field1,field2,….. from tab WHERE IF(problem_status==1,'Open','Closed') = "Open";
After that, it should give expected results.