Does grid template support mysql?
I want to use the aw grid to display and edit data but i cant get it to work. Does aw template mysql
I have a deadline comin up and it wud be great if i could get this goin 2day
Here is my code:
I keep getting a " 'My' is undefined " error .
I so frustrated now i feel like packin in aw alltogether and using something else.
Thanks for help
I have a deadline comin up and it wud be great if i could get this goin 2day
Here is my code:
<html>
<head>
<title>PHP table</title>
<style> body, html {margin:0px; padding: 0px; overflow: hidden;} </style>
<!-- ActiveWidgets stylesheet and scripts -->
<link href="..runtime/styles/xp/grid.css" rel="stylesheet" type="text/css" ></link>
<script src="../runtime/lib/grid.js"></script>
<!-- ActiveWidgets PHP functions -->
<?php include("activewidgets.php") ?>
<!-- grid format -->
<style>
.active-templates-input {
overflow: hidden;
width: 100%;
height: 100%;
padding: 0px 5px;
margin: -1px 0px;
border: 1px solid #666;
vertical-align: middle;
font: menu;
line-height: 1.4em;
}
.active-templates-input.gecko {
display: block;
margin: 0px;
}
</style>
<!-- grid data -->
<script>
if (!window.My) My=[];
if (!My.Templates) My.Templates=[];
My.Templates.Input = Active.Templates.Text.subclass();
My.Templates.Input.create = function()
{
var obj = this.prototype;
// editor is not part of the template,
// there is only one single instance of editor object.
var editor = new Active.HTML.INPUT;
editor.setClass("templates", "input");
editor.setAttribute("type", "text");
editor.setAttribute("value", function(){
return template.getItemProperty("text");
});
// template variable provides temporary reference
// to the parent template during edit mode.
var template;
function switchToEditMode(){
if (template) {
switchToTextMode()
}
template = this;
template.element().style.padding = 0;
template.element().innerHTML = editor;
editor.element().focus();
}
obj.setEvent("ondblclick", switchToEditMode);
function switchToTextMode(){
var value = editor.element().value;
template.setItemProperty("text", value);
template.refresh();
template = null;
}
editor.setEvent("onblur", switchToTextMode);
};
My.Templates.Input.create();
var myData = new Array();
<?
$link = mysql_connect("127.0.0.1", "****", "******");
// echo "Connection made";
mysql_select_db("test");
register_shutdown_function($close);
$sql = "Select `Hostname` , `Spec` , `Booked_By` , `Project` , `Subproject` ,`Proj_Mgr`, `Dept_Mgr`, `Purpose`, `Comments`, `TestSite_Type` from `tp`";
$result = mysql_query($sql , $link);
while ( $row = mysql_fetch_array($result))
{
echo 'myData.push["'.$row['Hostname']
.'","'.$row['Spec']
.'","'.$row['Booked_By']
.'","'.$row['Project']
.'","'.$row['Subproject']
.'","'.$row['Proj_Mgr']
.'","'.$row['Dept_Mgr']
.'","'.$row['Purpose']
.'","'.$row['Comments']
.'","'.$row['TestSite_Type'].'"'
.']';
}
?>
var myColumns = [ "Hostname", "Spec", "Booked_By", "Project", "Subproject" , "Proj_Mgr" , "Dept_Mgr" , "Purpose" ,"Comms" , "TestSite_Type" ];
</script>
</head>
<body>
<script>
// create ActiveWidgets Grid javascript object
var obj = new Active.Controls.Grid;
// set number of rows/columns
obj.setRowCount(20);
obj.setColumnCount(5);
// provide cells and headers text
// create editable text template
var templ = new My.Templates.Input;
// assign new template to all columns
obj.setColumnTemplate(templ);
// provide methods for getting and setting data
obj.getDataText = function(i, j){return myData[i][j]};
obj.setDataText = function(value, i, j){myData[i][j] = value};
obj.setColumnText(function(i){return myColumns[i]});
// disable arrow key nevigation
obj.setEvent("onkeydown", null);
// make input box selectable
obj.getTemplate("top").setEvent("onselectstart", obj.getEvent("onselectstart"));
obj.setEvent("onselectstart", null);
// set click action handler
//obj.setAction("click", function(src){window.status = src.getProperty("item/text")});
// write grid html to the page
document.write(obj);
</script>
</body>
</html>
I keep getting a " 'My' is undefined " error .
I so frustrated now i feel like packin in aw alltogether and using something else.
Thanks for help
VERY-UPSET-DUDE
August 24,