3.0 beta 2

How to insert oracle table data into grid..

Hello,
I need to retrieve oracle table data around 10 columns and display it in the grid.

Can anyone help me.. how to do this ?

thanks in advance.
Krvmla.
krvmla
February 10,
Look at /examples directory in the distribution package. It has few samples for ASP and PHP and also working directly with XML output.
Alex (ActiveWidgets)
February 10,
Try the Oracle XSQL servlet if you dont know PHP/JSP/ASP
Alex
February 18,
I just finished putting it together in PHP based on the PHP example and made a nice little include file.

Here's the code in my inc.dbfuncs.php include file:
<?php
// **************************************************************************
//This function creates an array with the given query
//
//Programmer: RFair
//Date: 8/1/2006
// **************************************************************************
// **************************************************************************
function getDataToArray($conn,$sql) {
//Parse and run the SQL statement
$sql = stripslashes($sql);
$statement = oci_parse($conn, $sql);
oci_execute($statement);

//Get the data
$nrows = oci_fetch_all($statement, $results);

//Close the SQL transaction
oci_free_statement($statement);

//Return the resultset
return $results;
}

// **************************************************************************
//This function creates a JavaScript array with the given resultset
// to be used as the cell data in an AW grid
//
//Programmer: RFair
//Date: 8/1/2006
// **************************************************************************
// **************************************************************************
function aw_cells($dataset){
$rowCount = (count($dataset,COUNT_RECURSIVE) - count($dataset))/count($dataset);
$rows = array();
for ($i = 0; $i < $rowCount; $i++) {
$vals = array();
foreach ($dataset as $col) {
$vals[] = '"'.addslashes($col[$i]).'"';
}
$rows[] = "\t[".implode(",", $vals)."]";
}
$dataCells = "[\n".implode(",\n",$rows)."\n];\n";
return $dataCells;
}

// **************************************************************************
//This function creates a javascript array with the given resultset
// to be used as the header names in an AW Grid
//
//Programmer: RFair
//Date: 8/1/2006
// **************************************************************************
// **************************************************************************
function aw_headers($dataset){
foreach ($dataset as $key => $val) {
$cols[] = '"'.$key.'"';
}
$dataHeaders = "[".implode(",",$cols)."];\n";
return $dataHeaders;
}
?>





Then you put this code in your base php file:

<?php
//Include the db Funcs
include('includes/inc.dbFuncs.php');

//Get my data into a resultset
$dataArray = getDataToArray($conn,"SELECT * FROM CLASSES");
?>
<html>
<head>
<title>Oracle Example</title>
<link href="runtime/styles/aqua/aw.css" rel="stylesheet"></link>
<script src="runtime/lib/aw.js"></script>
<style>
.aw-alternate-even {background: #eeeeee;}
.aw-row-selector {text-align: center}
.aw-mouseover-row {background: #def;}
</style>
</head>
<body bgcolor="#FFFFFF">
<script>
//Insert javascript arrays produced by PHP functions
var myHeaders = <?= aw_headers($dataArray) ?>
var myCells = <?= aw_cells($dataArray) ?>

//Build the DataGrid Object
var obj = new AW.UI.Grid;
obj.setSize(600, 300);

//Set up the headers and data
obj.setHeaderText(myHeaders);
obj.setCellText(myCells);

//Set the number of columns/rows
obj.setColumnCount(myHeaders.length);
obj.setRowCount(myCells.length);

//Set up the Grid formatting
obj.setCellEditable(false);
obj.setSelectorVisible(true);
obj.setSelectorText(function(i){return this.getRowPosition(i)+1});
obj.onCellClicked = function(event, col, row){window.status = this.getCellText(col, row)};
document.write(obj);
</script>
</body>
</html>

Randy Fair (www.deweye.com rfair@deweye.com)
August 2,

This topic is archived.

See also:


Back to support forum

Search

Version 2

Looking for AW 2.6 ?
The old site is here.