Difference between revisions of "Using Parameters Views"

From Lianjapedia
Jump to: navigation, search
(Created page with "Using Parameterized Views Lianja 4.1 introduced parameterized views. Parameterized views are implemented using "Named parameters" in desktop/web/mobile Apps to query Virtual...")
 
Line 1: Line 1:
Using Parameterized Views
 
 
 
Lianja 4.1 introduced parameterized views.
 
Lianja 4.1 introduced parameterized views.
  

Revision as of 03:00, 26 April 2018

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

section.clearNamedParameters()
section.setNamedParameter(“name”, “value”)
section.reOpenTable()

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.

pname=string
pname=c:string
pname=n:number

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

Example

//
// 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")
mysection.reOpenTable()

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