echo"<TABLE WIDTH='100%' HEIGHT='55%' ALIGN='left' BORDER='0' CELLPADDING='2' CELLSPACING='2' BGCOLOR='#CCDDFF'>";
echo"<TR HEIGHT='25%'>";
echo"<TD COLSPAN='4' WIDTH='100%' ALIGN='left'>";
include "activewidgets.php";
$name = "obj";
echo activewidgets_grid_load($name, $dabs_searchedcodes);
echo"</TD>";
echo"</TR>";
echo"</TABLE>";
<?php
//This function creates the javascript code to load the
//active widgets grid based on the data array sent in.
function activewidgets_grid_load($name, &$data){
//How many rows are there. We need to tell the
//grid how much data we've got.
$row_count = @mssql_num_rows($data);
//How many columns are there. We need this to
//set the column header text and to build the
//array for the data.
$column_count = @mssql_num_fields($data);
//Get all the column names and create the
//array to make the column header in the grid.
$columns = "var ".$name."_columns = [\n";
for ($i=0; $i < $column_count; $i++) {
$field = @mssql_fetch_field($data, $i);
$columns .= "\"".$field->name."\", ";
}
$columns .= "\n];\n";
//Get all the data in the rows in an array
//we will use to fill the grid.
$rows = "var ".$name."_data = [\n";
while ($result = @mssql_fetch_array($data)) {
$rows .= "[";
for ($l=0; $l < $column_count; $l++) {
$rows .= "\"".$result[$l]."\", ";
// $rows .= "\"".activewidgets_html($result[$l])."\", ";
}
$rows .= "],\n";
}
$rows .= "];\n";
//echo "rows = $rows <br>";
//Finally! We are creating the javascript code that creates and formats
//the grid. When this funciton is called from a php page using "echo",
//this javascript code executes and magically create the grid.
$html = "<"."script".">\n";
$html .= $columns;
$html .= $rows;
$html .= "try {\n";
$html .= " var $name = new Active.Controls.Grid;\n";
$html .= " $name.setRowCount($row_count);\n";
$html .= " $name.setColumnCount($column_count);\n";
$html .= " $name.setDataText(function(i, j){return ".$name."_data[i][j]});\n";
$html .= " $name.setColumnText(function(i){return ".$name."_columns[i]});\n";
$html .= " var message = function(){";
$html .= " window.status = \"Grid selection:\" + ";
$html .= " \" latest=\" + this.getSelectionProperty(\"index\") + ";
$html .= " \" full list=\" + this.getSelectionProperty(\"values\") + ";
$html .= " \" (press Ctrl- to select multiple rows).\"";
$html .= " }\n";
$html .= " document.write($name);\n";
$html .= "}\n";
$html .= "catch (error){\n";
$html .= " document.write(error.description);\n";
$html .= "}\n";
$html .= "</"."script".">\n";
return $html;
}
?>
This topic is archived.