Grid does not load - error Expected ']'

Ok my grid won't load,

Heres my code;

<%@ LANGUAGE = VBscript %>
Dim oConnection
Dim oRecordset

Set oConnection = Server.CreateObject("ADODB.Connection")
oConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("vcms.mdb")

Set oRecordset = oConnection.Execute("SELECT DISTINCT volunteers.vid, volunteers.lname, volunteers.fname, volunteers.vdphone, volunteers.vephone, volunteers.vemail, volunteers.assigned, volunteers.date_assigned, volunteers.contacted, volunteers.vaddress, volunteers.vapt, volunteers.vcity, volunteers.vcounty, volunteers.vstate, volunteers.vzip, volunteers.spt, volunteers.lpc, volunteers.fund, volunteers.scomp, volunteers.inc, volunteers.vdob, volunteers.esname, volunteers.occ, volunteers.esaddress, volunteers.escity, volunteers.esstate, volunteers.eszip, volunteers.egroup, volunteers.ecname, volunteers.ecrel, volunteers.ecphone, volunteers.cont_by, volunteers.dofi, volunteers.vssn, legal.b_check, legal.bstatus, legal.pdate_sub, legal.r FROM (SELECT * FROM (SELECT volunteers.*, interest.*, legal.*, committee.*, certs.*, coach.* FROM ((((volunteers INNER JOIN interest ON volunteers.vid = interest.vid) INNER JOIN legal ON volunteers.vid = legal.vid) LEFT JOIN committee ON volunteers.vid = committee.vid) LEFT JOIN certs ON volunteers.vid = certs.vid) LEFT JOIN coach ON volunteers.vid = coach.vid)) WHERE NOT (bstatus = 'Denied') AND NOT(bstatus = 'Inactive')")

function aw_string(s)

rem s = Replace(s, "\", "\\")
rem s = Replace(s, """", "\""") 'replace javascript control characters - ", \
rem s = Replace(s, vbCr, "\r")
rem s = Replace(s, vbLf, "\n")

aw_string = """" & s & """"

end function

function aw_headers(oRecordset)

Dim i, count, headers()

count = oRecordset.fields.count
ReDim headers(count-1)

For i=0 to count-1
headers(i) = aw_string(oRecordset(i).name)

Response.write("[" & Join(headers, ", ") & "];")

end function

function aw_cells(oRecordset)

Dim i, col_count, row_count, columns(), rows()

row_count = 0
col_count = oRecordset.fields.count
ReDim columns(col_count-1)

Do while (Not oRecordset.eof)

For i=0 to col_count-1
columns(i) = aw_string(oRecordset(i))

ReDim preserve rows(row_count)

rows(row_count) = vbTab & "[" & Join(columns, ", ") & "]"
row_count = row_count + 1


Response.write("[" & vbNewLine & Join(rows, "," & vbNewLine) & vbNewLine & "];" & vbNewLine)

end function

<script src="../../runtime/lib/aw.js"></script>
<link href="../../runtime/styles/xp/aw.css" rel="stylesheet"></link>


// insert javascript arrays produced by ASP functions
var myHeaders = <%= aw_headers(oRecordset) %>
var myCells = <%= aw_cells(oRecordset) %>

// create grid control
var obj = new AW.UI.Grid;

// set grid text

// set number of columns/rows

// write grid to the page


it throws a javascript error "Expected ']'"
January 25,
Firefox does throw an error, but the grid never loads
January 25,
sorry didn't finish the last post, all the data is pulled correctly into the js array. The grid just won't load. I think this library shows great promise for us if I can get it to load the grid.

Any help will be greatly appreiated
January 25,
ugh!!! firefox does NOT throw an error
January 25,
I'm not strong with VBscript but after looking at your code, I think I can see something that might cause your problem:

In the function "function aw_headers(oRecordset)" you have the line

Response.write("[" & Join(headers, ", ") & "];")

You are trying to create the headers for the grid but after you have written the headers, you have an extra "," when a "]" is expected instead.

You have it as such: ["header1","header2","header3","header4",];

When it should read like this: ["header1","header2","header3","header4"];
You just need to remove that "," after the last header item.

I daresay that the same problem will occur within the aw_cells(oRecordset) function.

Give that a go..

The grid is great! You just need to overcome this initial obstacle - I have successfully incorporated the grid into my site and it looks great.

January 26,
Try to remove all javascript code except these two lines -

var myHeaders = <%= aw_headers(oRecordset) %>
var myCells = <%= aw_cells(oRecordset) %>

If you still has an error it means the problem is with your data array. Either extra comma at the end or some special characters inside your text. Try to enable all Replace() calls in aw_string function.
Alex (ActiveWidgets)
January 26,

This topic is archived.

See also:

Back to support forum