Q:
With a dynamic array, is there a built-in function to check whether a specified element exists?
A:
PEMSTATUS()
Also, the GETMEMBER() function returns the value of a dynamic array element or an alternative value if the element does not exist.
The Lianja.getElementByID(item) method and its (quicker to type) synonym Lianja.get(item) allow you to call methods and get and set properties of the visual elements in the Lianja Object Model (LOM) hierarchy, from App through Pages and Sections to Formitems, Gadgets and Columns.
Q:
Are these two the same? I have had some strange results using the first syntax
Code:
loPge = Lianja.get("page1")
loSec = loPge.section1
and
Code:
loSec = Lianja.get("page1.section1")
this works:
Code:
loSec = Lianja.get("Purchase_Orders.section1")
loSec.add()
but this doesn't:
Code:
loPge = Lianja.get("Purchase_Orders")
loSec = loPge.section1
loSec.add()
A:
The normal approach to referencing UI elements is to use Lianja.get() with dotted notation for page.section.formitem.
You get an object reference then set its attributes and call it's methods in the way I previously described. This is scripting language independent.
Q:
I'm using canvases a lot in my app for the added flexibility they bring. In a desktop app, you can access (for example) the text in field1 of a canvas with
Code:
var myvar = Lianja.get("page1.section1.field1").text
In non-desktop apps this seems to fail. I've tried running that both client- and server-side to the same result. Running in the JavaScript console in the web app debugger
Code:
Lianja.get("page1.section1.field1").text
returns "".
This makes me think the feature isn't implemented in non-desktop apps? If not, is there a different way of doing it? I find this functionality really useful in a lot of ways, for example setting the default value of a textbox dynamically based on what the user entered on a previous page.
A:
In JavaScript web and mobile apps they have a JavaScript object variable declared automatically as the ID of the UI control so naming is important.
in your case here you would name field2 something sensible and just reference the properties as field2.property.
Also look at the toJSON() method on sections if you want to gather all data off a form to send to a server side procedure for processing. Use this in conjunction with base64_encode() and base64_decode() on the server.
Q:
Code:
cat = Lianja.get('Advanced_Search.section1').field13
val_cat = cat.text
cat.text
Variable was expected!
A:
That is invalid syntax.You should use.
Code:
cat = Lianja.get('Advanced_Search.section1.field13')
Lianja v2.1 includes two new methods on Pages, Sections and FormItems (fields and gadgets).
These are setAttribute(name, value) and getAttribute(). These methods handle all attributes as documented and described in the MetaType Editor.
e.g.
Use Lianja.get("page1").setAttribute("title", "page title") for pages.
Use Lianja.get("page1.section1").setAttribute("title", "section title") for sections.
Use Lianja.get("page1.section1.field1").setAttribute(" caption", "field caption") for formitems.
Note that there are shortened forms of these also, setAttr() and getAttr() respectively.
Q:
I have a custom commandbutton class that I want to reuse. Meaning, I have several buttons created using "Mybuttons".
I want to pass a unique id to click event so that I know which button was clicked.
Something like below.
Code:
define class mybuttons as commandButton
proc click( param1)
do case
.....
endcase
endproc
enddefine
A:
create your button and assign it a unique id. In the click event you can then reference this.id.
this.name works fine.
Q:
When an App is open in App Builder, is it and it's objects available in the Console?
A:
Code:
? Lianja.get("page.section.control").text
Q:
Wher is .hwnd properties in Form object ?
How do use hwnd to get the id for a section, or a gadget?
I need to redirect video output to a window.
A;
hwnd is a artifact of the (old -- WPF and Silverlight don't have hwnd, but have hwnd interop) windows technology. The purpose was to give a near-object reference in a non-object-oriented environment.
In LianjaDemo, from the console:
Code:
lo = lianja.get("customers")
? lo.hwnd
Q:
May I know how I can get an object reference to the Current App, Current Page, Current Section, Current field and Current Gadget in my delegate?
In other words, is there something similiar to This and Thisform in VFP for the App, Page, Section, Field and Gadget
A:
Code:
loMyControl = Lianja.activepage.activesection.activecontrol
For active page:
Code:
oactivePage = Lianja.activePage
nameactivePage = Lianja.activePage.id
Section:
Code:
oactiveSection = Lianja.get("mypage").activesection
Lianja.localstorage.setItem( key, value )
and
Code:
Lianja.sessionstorage.setItem( key, value )
And the corresponding getItem() on these work between desktop and web//mobile
_screen is VFP desktop specific and does not exist in the web client.
All topics in [Answers] alphabetically:http://www.lianja.com/community/showthread.php?2717-Answers
Bookmarks