
Fabio - 2011-03-18 14:11:23
Is it possible to pass a value via GET to the grid? I have tried to use addparams, but the GET gets cleared. I also tried to add the variable as a session variable, but that is also not working. Any Suggestions?
<code>
<?php
$INC_DIR = $_SERVER["DOCUMENT_ROOT"]. "/lib";
define("PATHDRASTICTOOLS", "$INC_DIR/dt/");
session_start();
if (isset($_GET[partno])) {
$_SESSION[partno] = $_GET[partno];
}
$server="localhost";
$user="xxx";
$pw="xxx";
$db="xxx";
$table="material";
$partno = $_SESSION[partno];
include(PATHDRASTICTOOLS."drasticSrcMySQL.class.php");
class mysrc extends drasticSrcMySQL {
protected function select(){
$res = mysql_query("SELECT * FROM $this->table WHERE partno = '$partno'" . $this->orderbystr, $this->conn) or die(mysql_error());
return ($res);
}
protected function add(){
mysql_query("INSERT INTO $this->table (partno) VALUES('$partno')", $this->conn) or die(mysql_error());
if (mysql_affected_rows($this->conn) == 1) return(true); else return(false);
}
}
$options = array(
"add_allowed" => true,
"delete_allowed" => true,
"editablecols" => array("description", "price", "qty"),
);
$src = new mysrc($server, $user, $pw, $db, $table, $options);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<link rel="stylesheet" type="text/css" href="/lib/dt/css/grid_default.css"/>
<title>Quote Sheet</title>
</head><body>
<script type="text/javascript" src="/lib/dt/js/mootools-1.2-core.js"></script>
<script type="text/javascript" src="/lib/dt/js/mootools-1.2-more.js"></script>
<script type="text/javascript" src="/lib/dt/js/drasticGrid.js"></script>
<? echo $partno ?>
<div id="grid1"></div>
<script type="text/javascript">
var thegrid = new drasticGrid('grid1', {
pathimg:"/lib/dt/img/",
sliderposition: "left",
pagelength: "5",
addparams: "&partno=<?php echo $partno ?>",
columns: [
{name: 'description'},
{name: 'price'},
{name: 'qty'}
]
});
</script>
</body></html>
</code>