:: Forum >> Version 1 >>

error : My is undefined in template

Im trying to make my table editable but i keep getting the following error:My is undefined
Thanks for all the help
Here is my code:

<html>

<
head>

    <
title>Hardware Requests :: PHP Example</title>
    <
stylebodyhtml {margin:0pxpadding0pxoverflowhidden;fontmenu;bordernone;}   </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>
         <
script src='edit.js'></script>
    <!-- 
ActiveWidgets PHP functions -->
    <
?php include("activewidgets.php"?>

    <!-- 
grid format -->

</
script>

 <
style>
        .
active-templates-input {
            
overflowhidden;
            
width100%;
            
height100%;
            
padding0px 5px;
            
margin: -1px 0px;
            
border1px solid #666;
            
vertical-alignmiddle;
            
fontmenu;
            
line-height1.4em;
        }

        .
active-templates-input.gecko {
            
displayblock;
            
margin0px;
        }

   </
style>
    <
script>

if (!
window.MyMy=[];
if (!
My.TemplatesMy.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;
        var 
originalVal template.getItemProperty("text");

        if(
originalVal != value){
            
template.setItemProperty("text"value);
        }
        
template.refresh();
        
template null;
    }

    
editor.setEvent("onblur"switchToTextMode);
};

My.Templates.Input.create();


var 
myData = new array();

<
?php
 
include 'dbconnect.php';
    
$arrayname myData;
$name1 =  $_POST['mynames'];

 
//grid object name
$name "obj";

// SQL query
$query "Select `Hostname` , `Spec` , Booked_By , `Project` , `Subproject` ,`Proj_Mgr`, `Dept_Mgr`, `Purpose`, `Comments`, `TestSite_Type` from `tp` where `Dept_Mgr` = '$name1'" ;


// database connection
$resultset1 = new DB();
$resultset1->DB1();
if (!
$resultset1) {
   die(
'Invalid query: ' mysql_error());
   }

 
//query results
  
$data =  $resultset1->query($query);

 while ( 
$row mysql_fetch_array($data) )
{
echo 
"myData.push[".$row['Hostname']."]";
echo 
"myData.push[".$row['Spec']."]";
echo 
"myData.push[".$row[' Booked_By ']."]";
echo 
"myData.push[".$row['Project']."]";
echo 
"myData.push[".$row['Subproject']."]";
echo 
"myData.push[".$row['Proj_Mgr']."]";
echo 
"myData.push[".$row['Dept_Mgr']."]";
echo 
"myData.push[".$row['Purpose']."]";
echo 
" myData.push[".$row['Comments']."]";
echo 
" myData.push[".$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(ij){return myData[i][j]};
    
obj.setDataText = function(valueij){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
redchord
Tuesday, August 23, 2005
Not sure, but just an idea, (missing "dot").
But then the message must say "Active is Undefinned" instead "My".
Is this???

<link href="./runtime/styles/xp/grid.css" rel="stylesheet" type="text/css" ></link
    <
script src="./runtime/lib/grid.js"></script
 
See the two "dots" before "/" in basic sample
<link href="../../runtime/styles/xp/grid.css" rel="stylesheet" type="text/css" ></link>
    <
script src="../../runtime/lib/grid.js"></script>
 
Tuesday, August 23, 2005
well it workrd b4 i changed mydata to this:


var myData = new array();

<
?php
include 'dbconnect.php';
    
$arrayname myData;
$name1 =  $_POST['mynames'];

//grid object name
$name "obj";

// SQL query
$query "Select `Hostname` , `Spec` , Booked_By , `Project` , `Subproject` ,`Proj_Mgr`, `Dept_Mgr`, `Purpose`, `Comments`, `TestSite_Type` from `tp` where `Dept_Mgr` = '$name1'" ;


// database connection
$resultset1 = new DB();
$resultset1->DB1();
if (!
$resultset1) {
   die(
'Invalid query: ' mysql_error());
   }

//query results
  
$data =  $resultset1->query($query);

while ( 
$row mysql_fetch_array($data) )
{
echo 
"myData.push[".$row['Hostname']."]";
echo 
"myData.push[".$row['Spec']."]";
echo 
"myData.push[".$row[' Booked_By ']."]";
echo 
"myData.push[".$row['Project']."]";
echo 
"myData.push[".$row['Subproject']."]";
echo 
"myData.push[".$row['Proj_Mgr']."]";
echo 
"myData.push[".$row['Dept_Mgr']."]";
echo 
"myData.push[".$row['Purpose']."]";
echo 
" myData.push[".$row['Comments']."]";
echo 
" myData.push[".$row['TestSite_Type']."]";
}

?



 
instead of sumthin like this:

var myData = [
[
"1","MP1""<input type='text' class='arialfont8' name='edr1c1' value='MegaPipe 1' style='text-align: top; height: 30px; border-style: none;' >""<input type='text' class='arialfont8' name='edr1c2' value='1' style='text-align: top; height: 30px; border-style: none;' >""<input type='text' class='arialfont8' name='edr1c3' value='99.00' style='text-align: top; height: 30px; border-style: none;' >""<input type='text' class='arialfont8' name='edr1c4' value='99.00' style='text-align: top; height: 30px; border-style: none;' >""<select name='edr1c5' class='arialfont8' style='height:15px;'><option value='1'>Oregon</option></select>"],
[
"1","ROUTER1""<input type='text' class='arialfont8' name='edr2c1' value='Router Rental' style='text-align: top; height: 30px; border-style: none;' >""<input type='text' class='arialfont8' name='edr2c2' value='1' style='text-align: top; height: 30px; border-style: none;' >""<input type='text' class='arialfont8' name='edr2c3' value='99.00' style='text-align: top; height: 30px; border-style: none;' >""<input type='text' class='arialfont8' name='edr2c4' value='99.00' style='text-align: top; height: 30px; border-style: none;' >""<select name='edr2c5' class='arialfont8' style='height:15px;'><option value='1'>Oregon</option></select>"],
[
"1","VOICE1""<input type='text' class='arialfont8' name='edr3c1' value='Voice Line' style='text-align: top; height: 30px; border-style: none;' >""<input type='text' class='arialfont8' name='edr3c2' value='1' style='text-align: top; height: 30px; border-style: none;' >""<input type='text' class='arialfont8' name='edr3c3' value='99.00' style='text-align: top; height: 30px; border-style: none;' >""<input type='text' class='arialfont8' name='edr3c4' value='99.00' style='text-align: top; height: 30px; border-style: none;' >""<select name='edr3c5' class='arialfont8' style='height:15px;'><option value='1'>Oregon</option></select>"],
];

var 
myColumns = [ "ID""Item Lookup""Description""Quantity""Price""Tax Price""Tax Location"
]; 
any ideas?
Tuesday, August 23, 2005
Maybe deleting last comma in the array??
style='height:15px;'><option value='1'>Oregon</option></select>"] 
]; 
 
instead of :

style='height:15px;'><option value='1'>Oregon</option></select>"], 
];
 
Tuesday, August 23, 2005
no dats not it.

Im usin mysql database so i need 2 query the values, Is there a better way to do this :

var myData = new array();

<
?php
include 'dbconnect.php';
    
$arrayname myData;
$name1 =  $_POST['mynames'];

//grid object name
$name "obj";

// SQL query
$query "Select `Hostname` , `Spec` , Booked_By , `Project` , `Subproject` ,`Proj_Mgr`, `Dept_Mgr`, `Purpose`, `Comments`, `TestSite_Type` from `tp` where `Dept_Mgr` = '$name1'" ;


// database connection
$resultset1 = new DB();
$resultset1->DB1();
if (!
$resultset1) {
   die(
'Invalid query: ' mysql_error());
   }

//query results
  
$data =  $resultset1->query($query);

while ( 
$row mysql_fetch_array($data) )
{
echo 
"myData.push[".$row['Hostname']."]";
echo 
"myData.push[".$row['Spec']."]";
echo 
"myData.push[".$row[' Booked_By ']."]";
echo 
"myData.push[".$row['Project']."]";
echo 
"myData.push[".$row['Subproject']."]";
echo 
"myData.push[".$row['Proj_Mgr']."]";
echo 
"myData.push[".$row['Dept_Mgr']."]";
echo 
"myData.push[".$row['Purpose']."]";
echo 
" myData.push[".$row['Comments']."]";
echo 
" myData.push[".$row['TestSite_Type']."]";
}

?
because im not sure if its rite. heres the dbconnection.php code:

<html>

<head>
<title></title>
</head>

<body>

<?php
class DB {

function DB1() {
$this->host = "127.0.0.1";
$this->db = "test";
$this->user = "root";
$this->pass = "123456";
$this->link = mysql_connect($this->host, $this->user, $this->pass);
// echo "Connection made";
mysql_select_db($this->db);
register_shutdown_function($this->close);
}
function query($query){
$result = mysql_query($query, $this->link);

return $result;
}
function close() {
mysql_close($this->link);
}

}
?>

<?php




?>
</body>

</html>

im very new to this. Thank you for your help
redchord
Tuesday, August 23, 2005
This statement will not work:
while ( $row mysql_fetch_array($data) ) 

echo 
"myData.push[".$row['Hostname']."]"
echo 
"myData.push[".$row['Spec']."]"
echo 
"myData.push[".$row[' Booked_By ']."]"
echo 
"myData.push[".$row['Project']."]"
echo 
"myData.push[".$row['Subproject']."]"
echo 
"myData.push[".$row['Proj_Mgr']."]"
echo 
"myData.push[".$row['Dept_Mgr']."]"
echo 
"myData.push[".$row['Purpose']."]"
echo 
" myData.push[".$row['Comments']."]"
echo 
" myData.push[".$row['TestSite_Type']."]"

 
With this you are adding new rows to the array not just adding one row with many items. Try and change it to:

while ( $row mysql_fetch_array($data) ) 
{
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'].'"'.
']';
}
 
I didn't test this but it should work.
Jim Hunter
Tuesday, August 23, 2005
dat got rid of dat my undefined error . cheers Still not fully working . im just goin 2 run a few tests and see.
redchord
Wednesday, August 24, 2005
i didnt see this syntex error;

while ( $row mysql_fetch_array($data) )
{
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'].'"'.
']';
i got rid of the dot at the end of each line but the My is undefined error is back. Here is my full code:

<html>

<
head>

    <
title>Hardware Requests :: PHP Example</title>
    <
stylebodyhtml {margin:0pxpadding0pxoverflowhidden;fontmenu;bordernone;}   </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>
         <
script src='edit.js'></script>
    <!-- 
ActiveWidgets PHP functions -->
    <
?php include("activewidgets.php"?>

    <!-- 
grid format -->

</
script>

 <
style>
        .
active-templates-input {
            
overflowhidden;
            
width100%;
            
height100%;
            
padding0px 5px;
            
margin: -1px 0px;
            
border1px solid #666;
            
vertical-alignmiddle;
            
fontmenu;
            
line-height1.4em;
        }

        .
active-templates-input.gecko {
            
displayblock;
            
margin0px;
        }

   </
style>
    <
script>

if (!
window.MyMy=[];
if (!
My.TemplatesMy.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;
        var 
originalVal template.getItemProperty("text");

        if(
originalVal != value){
            
template.setItemProperty("text"value);
        }
        
template.refresh();
        
template null;
    }

    
editor.setEvent("onblur"switchToTextMode);
};

My.Templates.Input.create();


var 
myData = new array();

<
?php
 
include 'dbconnect.php';
$name1 =  $_POST['mynames'];

 
//grid object name
$name "obj";

// SQL query
$query "Select `Hostname` , `Spec` , Booked_By , `Project` , `Subproject` ,`Proj_Mgr`, `Dept_Mgr`, `Purpose`, `Comments`, `TestSite_Type` from `tp` where `Dept_Mgr` = '$name1'" ;


// database connection
$resultset1 = new DB();
$resultset1->DB1();
if (!
$resultset1) {
   die(
'Invalid query: ' mysql_error());
   }

 
//query results
  
$data =  $resultset1->query($query);


 while ( 
$row mysql_fetch_array($data) )
{
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;
    
document.write("error not here");
    
// 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(ij){return myData[i][j]};
    
obj.setDataText = function(valueij){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
redchord
Wednesday, August 24, 2005
it says the error is on line 118 which is

.$row['Proj_Mgr'].'","'   i dont understand
redchord
Wednesday, August 24, 2005
how is the xml example usefull to me when im using a mysql database?
VERY-UPSET-DUDE
Thursday, August 25, 2005
look at this example...

http://www.poeticdata.com/griddemo/

this was my reference when i tried to may my AWgrid editable.
but be sure your data array is good.
glennlosentes
Friday, August 26, 2005



This topic is archived.

Back to support forum

Forum search