Using Parameterized Views

From Lianjapedia
Revision as of 03:33, 26 April 2018 by Barrymavin (Talk | contribs)

Jump to: navigation, search

Lianja 4.1 introduced parameterized views.

Parameterized views are implemented using "Named parameters" in desktop/web/mobile Apps to query Virtual Tables which contain ?parameters and {macros}.

Default values for named parameters can be specified in the Virtual Table "properties" e.g. "mycvar=hello;mynvar=n:123" etc.

The setNamedParameter(name, value) method on the Section section is used to dynamically specify named parameters.

Using parameterized views for virtual tables results in high performance queries that are dynamically generated based on user selections in the UI.

Basic method usage


Value notation

When setting a named parameter you can denote the data type so that any ?name parameter markers are substituted with the correct data type e.g numerics or ‘string’ constants. e.g.


Note that {macros} are substituted in place with no surrounding quotes.


// Assume we have a grid section which is bound to a VT called vcustomers
// and the vcustomers VT was created with
// create virtualtable vcustomers 
//     connstr “local” 
//     properties “pkwhere=1 eq 0“
//     as select * from southwind!customers {pkwhere}
mysection = Lianja.get(“page1.section1)
mysection.setNamedParameter("pkwhere", " where customerid like 'A%'")
// The special named parameter defaultnamedparameters when set to “0” causes
// default named parameters in the VT properties to be ignored
mysection.setNamedParameter("defaultnamedparameters", "0")

Note that javascript code in a Web / Mobile app is exactly the same except you should terminate each code statement with a semi colon.