Difference between revisions of "Working with the Lianja Object Model"
Yvonne.milne (Talk | contribs) |
Yvonne.milne (Talk | contribs) (→Lianja.getElementByID()) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 10: | Line 10: | ||
As a developer you can manipulate the properties and call methods on any of these visual elements in both development and runtime mode. This is accomplished using the [[Lianja|Lianja system object]] in any if the supported scripting languages: Lianja/Visual FoxPro, Python, PHP or JavaScript. | As a developer you can manipulate the properties and call methods on any of these visual elements in both development and runtime mode. This is accomplished using the [[Lianja|Lianja system object]] in any if the supported scripting languages: Lianja/Visual FoxPro, Python, PHP or JavaScript. | ||
− | The following examples are provided in Visual FoxPro syntax but they will work equally as well in Python, PHP or JavaScript | + | The following examples are provided in Visual FoxPro syntax but they will work equally as well in Python, PHP or JavaScript. |
==Lianja.getElementByID()== | ==Lianja.getElementByID()== | ||
Line 21: | Line 21: | ||
<code lang="recital"> | <code lang="recital"> | ||
− | + | oItem = Lianja.getElementByID("mypage") | |
</code> | </code> | ||
Line 27: | Line 27: | ||
<code lang="recital"> | <code lang="recital"> | ||
− | + | oItem = Lianja.getElementByID("mypage.mysection") | |
</code> | </code> | ||
Line 33: | Line 33: | ||
<code lang="recital"> | <code lang="recital"> | ||
− | + | oItem = Lianja.getElementByID("mypage.mysection.myitem") | |
− | + | cValue = oItem.value | |
</code> | </code> | ||
− | Note: The synonyms '''Lianja.get(item)''' and '''Lianja. | + | Note: The synonyms '''Lianja.get(item)''' and '''Lianja.findElementByID(item)''' are also available. |
==Lianja.item()== | ==Lianja.item()== | ||
Line 61: | Line 61: | ||
endfor | endfor | ||
</code> | </code> | ||
+ | |||
+ | ==Lianja.getElementByControlsource()== | ||
+ | |||
+ | From v5.3 the Lianja.getElementByControlsource(cSource) method offers an alternative way to reference data-bound UI [[:Category:Formitems|formitems]] ([[Advanced Canvas Control Attributes|Canvas Section advanced controls]], [[Field Attributes|fields]] and [[:Category:Attributes#Gadget_Attributes|gadgets]]). | ||
+ | |||
+ | The '''cSource''' corresponds to the formitem's [[Data_Attributes#Data_source|Data source]]. | ||
+ | |||
+ | ===Example=== | ||
+ | <code lang="recital"> | ||
+ | oItem = Lianja.getElementByControlsource("customers.customerid") | ||
+ | cValue = oItem.value | ||
+ | </code> | ||
+ | |||
+ | Note: The synonym '''Lianja.getControlSource(cSource)''' is also available. | ||
==Class Reference== | ==Class Reference== | ||
Line 79: | Line 93: | ||
− | [[Category: | + | [[Category:Developing in Lianja]] |
Latest revision as of 11:21, 4 May 2020
Contents
See Also
Understanding the Lianja App Architecture
Overview
Lianja Apps are built out of pages. Pages are built out of sections. There are a wide variety of built-in sections. Form sections for example are made up of FormItems and Gadgets. So as we can see, a Lianja App consists of a hierarchy of visual elements. This hierarchy we will refer to as the Lianja Object Model (LOM).
You can consider the whole of the Lianja App Builder as a meta-framework that you can use to develop Apps with.
As a developer you can manipulate the properties and call methods on any of these visual elements in both development and runtime mode. This is accomplished using the Lianja system object in any if the supported scripting languages: Lianja/Visual FoxPro, Python, PHP or JavaScript.
The following examples are provided in Visual FoxPro syntax but they will work equally as well in Python, PHP or JavaScript.
Lianja.getElementByID()
You can obtain a reference to the visual elements that make up your App using Lianja.getElementByID(item).
Examples
To get a reference to a page with the id mypage.
oItem = Lianja.getElementByID("mypage")
To get a reference to a section with the id mysection contained within the page mypage.
oItem = Lianja.getElementByID("mypage.mysection")
To get the current text in a FormItem with the id myitem in the section mysection contained within the page mypage use the following.
oItem = Lianja.getElementByID("mypage.mysection.myitem") cValue = oItem.value
Note: The synonyms Lianja.get(item) and Lianja.findElementByID(item) are also available.
Lianja.item()
Alternatively, use Lianja.item(position) to obtain a reference to the page at the specified position. This can be used with Lianja.count, which returns the total number of pages in the current App.
Pages and Sections also support the count property and the item() method, allowing you to traverse the complete LOM.
Example
for i=1 to Lianja.count oPage = Lianja.item(i) ? oPage.id for j=1 to oPage.count oSection = oPage.item(j) ? oSection.id for k=1 to oSection.count oFormitem = oSection.item(k) ? oFormitem.id endfor endfor endfor
Lianja.getElementByControlsource()
From v5.3 the Lianja.getElementByControlsource(cSource) method offers an alternative way to reference data-bound UI formitems (Canvas Section advanced controls, fields and gadgets).
The cSource corresponds to the formitem's Data source.
Example
oItem = Lianja.getElementByControlsource("customers.customerid") cValue = oItem.value
Note: The synonym Lianja.getControlSource(cSource) is also available.