The code below won't display the virtual column Degree of Loss-R, the console keeps telling me Uncaught SyntaxError: Invalid or unexpected token. Below are the versions of PHPGrid.
I think the problem has to do with the if statements in the formatter function, if I remove the call to add the virtual column dolr, the other columns work without any issues.
Any help will be greatly appreciated.
phpGrid(v6.1) {jqGrid:v4.5.2, jQuery:v1.9.0, jQuery UI:1.10.0}
<?php
$dolr_formatter = <<<DOLRFORMATTER
function(cellvalue, options, rowObject){
var p1 = parseInt(rowObject[5],10);
var n1 ="";
if (p1 < 26) {n1 = "Less than 25";}
if ((p1 > 24) && (p1 < 41)) {n1 = "Mild 25-40";}
if ((p1 > 39) && (p1 < 66)) {n1 = "Mod 40-65";}
if ((p1 > 64) && (p1 < 96)) {n1 = "Mod/Sev 65-85";}
if (p1 > 85) {n1 ="Pro 85+";}
return n1;
}
DOLRFORMATTER;
require_once("/var/www/html/phpGrid_Basic/conf.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://ift.tt/mOIMeg">
<html xmlns="http://ift.tt/lH0Osb" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Manage Data</title>
</head>
<body>
<?php
$col_formatter = <<<COLFORMATTER
function(cellvalue, options, rowObject){
var p1 = rowObject[4];
p1 = new Date(p1);
var n2 = new Date();
var n3 = Math.floor((n2-p1) / (365.25 * 24 * 60 * 60 * 1000));
return n3;
}
COLFORMATTER;
$dolr_formatter = <<<DOLRFORMATTER
function(cellvalue, options, rowObject){
var p1 = parseInt(rowObject[5],10);
var n1 ="";
if (p1 < 26) {n1 = "Less than 25";}
if ((p1 > 24) && (p1 < 41)) {n1 = "Mild 25-40";}
if ((p1 > 39) && (p1 < 66)) {n1 = "Mod 40-65";}
if ((p1 > 64) && (p1 < 96)) {n1 = "Mod/Sev 65-85";}
if (p1 > 85) {n1 ="Pro 85+";}
return n1;
}
DOLRFORMATTER;
$dg = new C_DataGrid("SELECT * FROM patient","lname","patient");
$dg -> enable_edit("INLINE", "CRUD");
$dg -> add_column(
'age',
array('name'=>'age',
'index'=>'age',
'width'=>'120',
'align'=>'left',
'sortable'=>true,
'formatter'=>$col_formatter),
'Age');
$dg -> add_column(
'dolr',
array('name'=>'dolr',
'index'=>'dolr',
'width'=>'120',
'align'=>'left',
'sortable'=>true,
'formatter'=>$dolr_formatter),
'Degree of Loss-R');
$dg -> set_multiselect(true);
$dg -> set_col_edittype("HAE_YN","select","NO:NO;YES:YES");
$dg -> set_caption('Patient Database');
$dg -> set_col_title("fname", "First Name");
$dg -> set_col_title("lname", "Last Name");
$dg -> set_col_title("account_num", "Account #");
$dg -> set_col_title("phy", "Physician Referral");
$dg -> set_col_title("DOB", "Date of Birth");
$dg -> set_col_title("PTA_L", "PTA-L");
$dg -> set_col_title("PTA_R", "PTA-R");
$dg -> set_col_title("HAE_YN", "HAE Yes/No");
$dg -> set_col_title("MONTH_YR", "Month Year");
$dg -> enable_search(true);
$dg -> set_scroll(true);
$dg -> set_dimension(1000,600);
$dg -> set_pagesize(40);
$dg -> display();
?>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire