help switching to server-side formatting

help switching to server-side formatting

gforstergforster Posts: 40Questions: 19Answers: 1
edited December 2013 in General
From the outset - I am not an ncredibly proficient php developer, so this is likely an easy problem to solve for some of you. I've been doing this client-side successfully and been getting all the formatting correct. I am struggling to convert into server side using the script here - http://datatables.net/development/server-side/php_mysql

The data is coming in just fine, it is the formatting of different columns I am struggling with. Here is one example - I have a certain column that looks like this using client-side:

[code]


<?php
if( is_null($row["FIELD1"]))
{echo "Not Started";}
elseif( is_null($row["Final"]) && ($row["Status"]==='1') && is_null($row["Create"]))
{echo "In Progress";}
elseif( is_null($row["Final"]) && ($row["Status"]==='0') && ($row["MAP"]==='1') && is_null($row["Create"]))
{echo "In Progress";}
elseif( is_null($row["Final"]) && ($row["Status"]==='0') && ($row["VAP"]==='1') && is_null($row["Create"]))
{echo "In Progress";}
elseif( is_null($row["Final"]) && ($row["Status"]==='0') && ($row["LAP"]==='1') && is_null($row["Create"]))
{echo "In Progress";}
elseif( is_null($row["Final"]) && isset($row["Create"]) && is_null($row["Synch"]))
{echo "In Progress";}
elseif( is_null($row["Final"]) && isset($row["Synch"]) && is_null($row["Config"]))
{echo "In Progress";}
elseif( is_null($row["Final"]) && isset($row["Config"]) && is_null($row["AllSet"]))
{echo "In Progress";}
elseif( is_null($row["Final"]) && isset($row["AllSet"]))
{echo "In Progress";}
else
{echo "Completedin ";} {echo($row["diff"]);} {echo "";}
?>


[/code]

I just can't figure out how to get that "Translated" to the format outlined here:
[code]
if ( $aColumns[$i] == "version" )
{
/* Special output formatting for 'version' column */
$row[] = ($aRow[ $aColumns[$i] ]=="0") ? '-' : $aRow[ $aColumns[$i] ];
}
[/code]

Simpler ones like this I have been able to figure out:

[code]
<?php echo date("m/d/Y H:i A", strtotime($row["SDate"]));?>


<?php if( is_null($row["Status"])){echo "Checking...";}else{echo ($row["Status"] ? 'yes': 'no');}?>


[/code]

"translates" to

[code]
if ( $aColumns[$i] == "SDate" )
{
$row[] = date("m/d/Y H:i A", strtotime(($aRow[ $aColumns[$i] ])));
}
else if ( $aColumns[$i] == "Status" )
{
$row[] = ($aRow[ $aColumns[$i] ]) ? 'yes' : 'no';
}
[/code]

Replies

  • gforstegforste Posts: 4Questions: 0Answers: 0
    Is there anyone that can help me with this? I am also unable to get something such as this working:
    [code]if ( $aColumns[$i] == "diff" )
    {
    $row[] = "Completed in $aRow($aColumns[$i])";
    }
    [/code]

    Instead it is displaying as "Completed in Array(diff)" instead of "Completed in 01 Hour 32 Minutes" (or whatever the time result is in the "diff" column.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Do you mean:

    [code]
    $row[] = "Completed in ".$aRow[$aColumns[$i]];
    [/code]

    Calling it as a function probably isn't working.

    It might be easier to use mRender on the client-side perhaps?

    Allan
  • gforstegforste Posts: 4Questions: 0Answers: 0
    Interesting. Will mRender allow for the if/else conditional displays as shown above?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Sure - its just a javascript function - you can put what you want in it.

    Allan
This discussion has been closed.