Forum Discussion
Can I query a table row count in the Presentation section of an iApp?
Is there a way to query the size of a table element in the APL language of an iAPP? The reason for asking is that I don't want to present an empty row if there hasn't been anything entered in that table row previously...
section servers_pool1 {
string poolname display "xxlarge" default "pool1"
string pooldesc display "xxlarge"
**optional ( count(poolmembers)>0)** {
table poolmembers {
string description display "large"
editchoice addr display "large" tcl {
package require iapp 1.1.0
return [iapp::get_items ltm node] }
optional ( serverside_encryption.encryption == "Plaintext" ) {
string port display "small" validator "PortNumber"
default "80"
}
optional ( serverside_encryption.encryption == "Encrypted" ) {
string port_secure display "small" validator "PortNumber"
default "443"
}
}
}
The statement marked ** is something I am looking for... ???
- cjunior
Nacreous
Hi Neil,
A way to perform is using a optional "HIDE = THIS". This way, the test fields will never appers on screen and you will get the expected results to present. In this case, I simply check the node count. You must change it to your query conditions needed.
section servers_pool1 { optional ( "HIDE" == "THIS" ) { choice has_nodes tcl { expr { [iapp::get_items ltm node] ne "" ? "yes" : "no" }} } string poolname display "xxlarge" default "pool1" string pooldesc display "xxlarge" optional ( has_nodes == "yes" ) { table poolmembers { string description display "large" editchoice addr display "large" tcl { package require iapp 1.1.0 return [iapp::get_items ltm node] } optional ( serverside_encryption.encryption == "Plaintext" ) { string port display "small" validator "PortNumber" default "80" } optional ( serverside_encryption.encryption == "Encrypted" ) { string port_secure display "small" validator "PortNumber" default "443" } } } }
Regards.
- candc
Cirrus
cjunior's answer works well if the condition is not user-editable, e.g "Have any nodes been created already?".
I wanted to make the empty table look nicer as well but, in the end, I had to redesign slightly, because I couldn't find any way to interact with the table from within Presentation.
Instead, I just made the overall question user-editable, i.e. "Do you want to add pool members?"
Perhaps consider:
choice pool_add_members default "no" { "yes", "no" } optional (pool_add_members == "yes") { table pool_members { ... } }
The end-result is that the user makes a decision upfront about whether there are any pool members and, if there are, the table is shown. It's one extra step for the user, but it looks a bit nicer when there are deliberately no entries.
Your Implementation code can test the $1 entry as well, and not enter the table loop if it is "no", which might be a bonus.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com