Get actual weblistbox row height

I’ve tried to get at this before. Let’s try again . . .

weblistbox.rowHeight(row) does not give the actual row height. It gives the minimum row height.

If I can get the actual row height I can create my own drag and drop.

How do I get the actual row height ???

Use http://www.w3schools.com/jsref/prop_element_offsetheight.asp

How do I get into the javascript?

http://documentation.xojo.com/index.php/ExecuteJavaScript

ok . . . so trying to understand javascript in Xojo. Just trying to declare my listbox in javascript

dim js as string
js = “var elmnt = document.getElemetByID(”"" + me.controlID + “”");"
me.executeJavaScript(js)

Gives me this error:

Could not execute returned javascript: Object doesn’t support property or method ‘getElemetByID’

[quote=237657:@John Scanlan]ok . . . so trying to understand javascript in Xojo. Just trying to declare my listbox in javascript

dim js as string
js = “var elmnt = document.getElemetByID(”"" + me.controlID + “”");"
me.executeJavaScript(js)

Gives me this error:

Could not execute returned javascript: Object doesn’t support property or method ‘getElemetByID’[/quote]

Javascript is case sensitive, D should be lowercase d, and you are missing the n. It should be :

dim js as string js = "var elmnt = document.getElementById(""" + me.controlID + """);" me.executeJavaScript(js)

Thanks . . . it was the lowercase ‘d’ that was messing me up. This got me the height of the listbox:

dim js as string
js = “var elmnt = document.getElementById(”"" + me.controlID + “”");" + endofline + _
“var txt = elmnt.offsetHeight;” + endofline + _
“document.getElementById(”"" + lblHeight.controlID + “”").innerHTML = txt;"

me.executeJavaScript(js)

Now I just need to break it down to height of a row

[quote=237667:@John Scanlan]Thanks . . . it was the lowercase ‘d’ that was messing me up. This got me the height of the listbox:

dim js as string
js = “var elmnt = document.getElementById(”"" + me.controlID + “”");" + endofline + _
“var txt = elmnt.offsetHeight;” + endofline + _
“document.getElementById(”"" + lblHeight.controlID + “”").innerHTML = txt;"

me.executeJavaScript(js)

Now I just need to break it down to height of a row[/quote]

The WebListBox is composed of several elements.

What you want to do is look at the actual code behind the WebListBox to see where the rows are. Run a project with a WebListBox on, then use the Developers Tools of the browser to look at the elements in the Dom.

…and remember that the structure of our controls is subject to change without notice.

Greg . . . How’s drag and drop between weblistbox(s) coming? That’s what I’m really trying to get to. Or, even if .rowHeight would provide the actual row height instead of the minimum height . . .

You know I can’t comment on that.

:slight_smile:

Getting closer: I’ve got the app telling me the height of the table. Can’t get it to tell me the height of each row.

While inserting rows into a table, I’ve got this running:

      jscript = "document.getElementById('" + cc.create.label2.controlID + "').innerHTML = " + _
      "window.getComputedStyle(document.activeElement,null).height"
      cc.create.label1.text = jscript
      cc.create.label2.ExecuteJavaScript(jscript)
      rowHeights.append cc.create.label2.text

label2 is initially set to “ltest.” rowHeights has the correct number of rows but it’s filled with “ltest”

Ideas?

Keep in mind that the JavaScript is run after your method is called. Not inline as you seem to expect it to be here.

Greg . . . That’s what I tried first but couldn’t identify each row to javascript.

Here is the significant code of a WebListBox which has one row, containing the text “test” :

[code]

Column 1  
[/code]

You should be able to traverse the hierarchy with getElementsByTagName.

Look in JavaScript for the offsetHeight of the cell.

test  

Hi Michel

I have a page name Webtest so how i add the javascript code and run it

This is just the code produced by Xojo for the WebListBox, not a program ready to apply.

Thanks Michel . . . just couldn’t get the value of computed rowHeight back from javascript

Check the WebSDK in the Extra folder. WebSDK.pdf starts with a simple control, and shows how to send a JavaScript value back to Xojo.