// print MySQL field names as javascript array
function aw_headers($dataset){
while ($field = @mysql_fetch_field($dataset)) {
$cols[] = '"'.$field->name.'"';
}
echo "[".implode(",",$cols)."];\n";
}
?>
<html>
<head>
<!-- include AW stylesheet and script -->
<link href="../../runtime/styles/xp/aw.css" rel="stylesheet" type="text/css" ></link>
<script src="../../runtime/lib/aw.js"></script>
</head>
<body>
<script>
// insert javascript arrays produced by PHP functions
var myHeaders = <?= aw_headers($dataset) ?>
var myCells = <?= aw_cells($dataset) ?>
// create grid control
var obj = new AW.UI.Grid;
// set grid text
obj.setHeaderText(myHeaders);
obj.setCellText(myCells);
// set number of columns/rows
obj.setColumnCount(myHeaders.length);
obj.setRowCount(myCells.length);
// write grid to the page
document.write(obj);
</script>
</body>
</html>
Alex (ActiveWidgets)
Wednesday, March 1, 2006
Oh, yeah, I didn't test the code. I only shrunk it. Actually you could also use mysql_fetch_assoc and acheive the same results. The problem with mysql_fetch_array is that you get the indexes as numbers and associate array indexes so you get the same number of rows. Just twice as many columns.
Tony
Thursday, March 2, 2006
I find it much easier to just consider my data and my widget separate.
use XML to present your fetch up and load it into the widget using the AW Table object.
Of course I have working with XUL for the past year and that may play into my view of how to go about doing this.
CKD
Thursday, March 23, 2006
when I test the code in server, I don´t see anything, the page is in blank why??? T_T...somebody can help me..please.
PD:sorry for my english I speak español
gracias
SEBA
Tuesday, May 9, 2006
Try looking at the HTML source of the "blank" page or the Javascript Console (if you use Firefox) to start looking for the error.
Mira el codigo fuente HTML de la página que parece estar en blanco, o la consola de Javascript para ver si hay algún error.
joakinen
Tuesday, May 9, 2006
Probé el código y funciona, verifica que la conexión a la base de datos sea la correcta, host, user y password y tambien tu sentencia SQL, el asunto de la consola es buena idea y en el código HTML en teoria deberías tener la variable myCells (a parte de otra bola de cosas) con los datos que has obtenido de tu consulta, en mi prueba se ve así:
... var myCells = [
["1","1","1","02/05/2005","01:44","-89 39 37","19 55 8","Area agricola de temporal","Campeche","Hopelchen","NO AFECTA","0","0","TERRA"],
["2","2","","02/05/2005","01:44","-90 3 49","19 42 20","Pastizal cultivado","Campeche","Campeche","NO AFECTA","0","0","TERRA"],
["3","2","2","02/05/2005","01:44","-90 3 18","19 41 45","Area agricola de temporal","Campeche","Hopelchen","NO AFECTA","0","0","TERRA"],
...
Si no ves está variable con tus datos dentro del código HTML, entonces tienes problemas con las variables arribas mencionadas
Raul
Tuesday, May 9, 2006
I am using the free trial version and i cannot see the resulting grid in my server, but it works good in my pc (localhost).
I supose this is the license protection.
Anyone knows something about this issue?
Estoy usando la versión de prueba y no puedo ver el grid resultante en mi servidor, perop funciona bien en mi pc (localhost).
Supongo que esta es la protección de licencia.
¿Alguien sabe algo acerca de este tema?
Guillermo Arias, Lima
Guillermo Arias
Friday, October 20, 2006
But... How do you save the data back to database?
Practical example needed - not full of geek talk
mike
Tuesday, February 20, 2007
SELECT * FROM myTable LIMIT ...
next|back HOW?
Valeri
Tuesday, February 20, 2007
how can i use multiple query and show it in the same table?
i am using cold fusion query and mssql database.
BELOW IS MY CODE WHICH RUNS CORRECTLY, BUT ONLY USE 1 QUERY.
my code:
var myData = [<cfoutput query="qSearch">["#qSearch.CurrentRow#","<A href='myform.cfm?RefNo=#ID#' target='_blank'>#ID#</a>","#TITLE#","#TYPE#","#COMMENT#","#DATE#","#ACTIONSTATUS#"],</CFOUTPUT>];
var columnTitles = new array();
columnTitles.add("ID", "MY<br>TITLE", "TYPE", "COMMENT", "DATE", "STATUS");
i am confused. anybody knows how? thanks.
ellisegirl
Wednesday, March 28, 2007
sugestion for function aw_cells by alex:
i think it's better to add trim() to the value to free from whitespace.
because i found error if i don't do that.
i Add this trimlike this:
foreach ($record as $value){
$value=trim($value);
echo $cellSeparator."\"".$value."\"";
$cellSeparator = ",";
}
Hi ,
I’m a total newbie and yet have found it pretty easy to setup.
I’m using PHP/MYSQL and found the simple example that was easy to cut and paste.
I want the grid to be “live”, so I looked a little further and added the following code. obj.setCellEditable(true);
var r = new AW.HTTP.Request;
r.setURL("updateSingleCell.php");
r.setRequestMethod("POST");
r.setParameter("column", column);
r.setParameter("row", row);
r.setParameter("text", text);
r.request();
r.response = function(data){
alert(data); // process response data
}
}
I lucked out and it worked with one exception. The data is not updating the database.
I believe that I need to setup the updateSingleCell.php file to handle the updating and found the following code example for this file. <?php
//updateSingleCell.php
echo "done";
?>
I’m thinking that this is missing a few things and the average guy would have no problems finishing this from this point but like I said I’m a newbie.
1. Connection Settings to mysql I think I got this one with something like this $connection = mysql_connect($host,$user,$password)
or die ("Couldn't connect to server.");
$db = mysql_select_db($database, $connection)
or die ("Couldn't select database.");
2. Processing Code
Some form of UPDATE ? not sure this is where I need help.
Seven
Sunday, June 10, 2007
you still need help? (That code doesn't work for me, but I have some other code that does)
comptech
Tuesday, June 26, 2007
Comptech... can you please post your code? I'm trying to do something similar and could use the example.
<!-- include links to the script and stylesheet files -->
<script src="runtime/lib/aw.js"></script>
<link href="runtime/styles/xp/aw.css" rel="stylesheet"></link>
<!-- change default styles, set control size and position -->
<style>
</style>
</head>
<body>
<?php
mysql_connect("localhost" , "root" , "") or die ( "Cannot connect to the database host, or the user/password is wrong. Check load.php" );
mysql_select_db("easy5") or die ("Check database. Current database (".$db.") does not exist.");
?>
<span id="myGrid"></span>
<script>
var obj = new AW.UI.Grid;
var grid = new AW.UI.Grid;
grid.setId("myGrid");
grid.setHeaderText(["Status", "Gebruikersnaam"]);
I am using the data grid in edit mode. I would like to know how to update the data that has been edited into my mysql database using ajax. Please help.
Regards,
Jay
Jay
Sunday, August 5, 2007
Hey every 1!
After reading and searching through the docs and forums and looking at the examples, it appears to me that the 2.0 Grid isn't natively setup to handle server side paging. Is this right?
Virtual rendering still loads all the data from the server and allows it to be scrolled through on the client side. Is this correct?