3.2.0

how to populate grid from recordset javascript

I am using JavaScript
I have connected to oracle
run query
now I need populate grid from recordset
please help me
thanks
tornado
October 4,
There are examples that come with the download.

Also look at -

http://www.activewidgets.com/grid.doc.data/

and -

http://www.activewidgets.com/grid.howto.data/

and the examples below it.
Anthony
October 5,
Antony
here is my script
could you please look and advice what's wrong
thanks

<!-- grid data -->
<script type="text/javascript">

            var conObj = new ActiveXObject('ADODB.Connection');
            var connectionString = "Driver={Microsoft ODBC for Oracle};CONNECTSTRING=orcl.com;uid=wibstar;pwd=qwerty;"
            conObj.Open(connectionString);
            var rs = new ActiveXObject("ADODB.Recordset");
            rs.Open("select name, lastname from users", conObj);

    
 	if(!rs.eof) 
 	{
  	     sRec=rs.GetString(2,-1,",","\n","&nbsp;");
   	     myData = sRecs.split(/\n/);
  	     for (var i=0; i<aRec.length; i++) 
  	     {
         myData[i]=myData[i].split(/,/);
       	 }
    }

    var myData = [
        s
    ];

    var myColumns = [
        "name", "lastName"
    ];
</script>
</head>
<body>
<script type="text/javascript">

    //	create ActiveWidgets Grid javascript object
    var obj = new AW.UI.Grid;
    obj.setId("myGrid");

    //	define data formats
    var str = new AW.Formats.String;
    var num = new AW.Formats.Number;

    obj.setCellFormat([str, str]);

    //	provide cells and headers text
    obj.setCellText(s);
    obj.setHeaderText(myColumns);

    //	set number of rows/columns
    obj.setRowCount(myData.length);
    obj.setColumnCount(myColumns.length);

    //	enable row selectors
    obj.setSelectorVisible(true);
    obj.setSelectorText(function(i){return this.getRowPosition(i)+1});

    //	set headers width/height
    obj.setSelectorWidth(28);
    obj.setHeaderHeight(20);

    //	set row selection
    obj.setSelectionMode("single-row");

    //	set click action handler
    obj.onCellClicked = function(event, col, row){window.status = this.getCellText(col, row)};

    //	write grid html to the page
    document.write(obj);
rs.close;
</script>
tornado
October 5,
or please advice recordset into a js array for the variable myData
thanks in advance
tornado
October 5,
I don't know how your ActiveX code works. Should that be in the HTML head section rather than the body?

You can view the page source after running it to see if your myData array gets populated. If its not, then the ActiveX code you have either isn't populating it or your SQL isn't returning a result.
Anthony
October 5,

This topic is archived.

See also:


Back to support forum