Uncaught TypeError when I click on a grid

Sometimes, when I click on a grid control, I receive this error:
Uncaught TypeError: Cannot read property ‘cells’ of undefined. line 87 column 33. (asFunctions.js is the title of the error).
My app is running under android.
This is an example of the grid:
image

Thanks.
David.

Do you have an onclick method for the grid?

Have a look at anything that refers to cells. My guess is that you are referring to a cell which does not exist.

I am assuming you are using the Common Grid. If you have an image in your grid it can cause the onclick event to register that cell as “undefined”. Even something as simple as <center>CLORO</center> in a cell will cause this as well. So, sometimes, depending on where you click in a cell, it will return the row and column ok, and sometimes not. When I want an image in a cell I use something like:

"<center><img  width = 44 height=40 src='other.jpg' id='grdDepart_0_0' align=Middle></center>"

The “id=…” seems to be what allows the onclick to work correctly. I also use the following when only text is involved:

s = "grdListMenu_" & iMenuRow & "_0"
Eval(s).style.textAlign="center" 

John

This happens for me if I tap/click on a grid line (either vertical or horizontal). I got around it by error checking the response

  s=Split(event.target.id, "_")
  ssRow = CSng(s(1))
  ssCol = CSng(s(2))
  If Not (ssRow+1)>0 Then Exit Function 'check valid row

Thanks.

I did as John suggested and also as lotsofcows did. I don’t receive the error any more but sometimes I have to click 3 or more times to “catch” a valid row or column.

David.

Not good if you have to click more than once. Look at the code/data that is in each of the cells of your grid (Grid1.getValue(row,col)). Break it down to it’s simplest by removing all html. If you have an image in a cell try putting in plain text to see if that makes a difference.

John

John: I removed all html and change text instead of an image. It seems to work better.
Thanks for your help.
David.