Various quantity parameters of tablePane

I have a tablePane. TablePane can have one, or two, or three parameters. It depends on some conditions.

At first I add all three parameters to tablePane.

set p1 = ##class(%ZEN.Auxiliary.parameter).%New()
set p1 .id = ..id1
do table.parameters.Insert(p1 )
do %page.%AddComponent(p1 )

 

set p2 = ##class(%ZEN.Auxiliary.parameter).%New()
set p2 .id = ..id2
do table.parameters.Insert(p2 )
do %page.%AddComponent(p2 )

 

set p3 = ##class(%ZEN.Auxiliary.parameter).%New()
set p3 .id = ..id3
do table.parameters.Insert(p3 )
do %page.%AddComponent(p3 )

 

Then through javascript I set parameters values and query names.

If there is one parameter, I set 

table.setProperty('queryName', 'QueryWithOnePar');

If there are two parameters:

table.setProperty('queryName', 'QueryWithTwoPars');

If there are three parameters:

table.setProperty('queryName', 'QueryWithThreePars');

 

Example of class queries

Query QueryWithOnePar(par1 As %String) As %SQLQuery
{
SELECT ID FROM Table WHERE (Field1 %STARTSWITH :par1)
}

 

Query QueryWithTwoPars(par1 As %String, par2 As %String) As %SQLQuery
{
SELECT ID FROM Table WHERE (Field1 %STARTSWITH :par1 AND Field2 = :par2)
}

 

Query QueryWithThreePars(par1 As %String, par2 As %String, par3 As %String) As %SQLQuery
{
SELECT ID FROM Table WHERE (Field1 %STARTSWITH :par1 AND Field2 = :par2 AND Field3 = :par3)

}

 

But this approach isn't working. After table.executeQuery the tablePane is empty. What I do wrong?

And how I can implement such approach, where tablePane can have various quantity of parameters?
 

Vote up!
Vote down!

Rating: 0

Comments: 1 Views: 39

Comments

To mark your question as "answered" on Developer Community, please click the checkmark alongside the answer you (as author of the question) accept.

Vote up!
Vote down!

Rating: 1

1 answer

Answer

I'd try to have just 1 query with 3 parameters and switch them on/off as you need

SELECT ID FROM Table WHERE (Field1 %STARTSWITH :par1 
AND ((0=:sw2) OR (
Field2 = :par2)) 
AND ((0=:sw3) OR (
Field3 = :par3))

Now using only par1  means (par1=whatever, sw2=0,sw3=0, par2="",par3="") so the 2nd + 3rd condition is switched off and par2,par3 ignored

2nd case: (par1=whatever,  par2=something, sw2=1,sw3=1, par3="") so only 3rd condition is switched off  par 3 ignored

3rd case: (par1=whatever,  par2=something, par3=other, sw2=1,sw3=1) all conditions active

you see this could be extended easily

 

 

Vote up!
Vote down!

Rating: 0

Log in to answer