-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi.
I want to show some columns in a grid. But I only want to show the columns that respect the following statement:
@load(vm.numCol)> 2
I've made some tests and the value of @load(vm.numCol) is 4.
But I'm trying to verify this condition this way:
<auxheader colspan="1" if="${@load(vm.numCol)>2}">
But I have this exception: org.zkoss.zel.ELException: Error Parsing: ${@load(vm.numCol)>2}
So I know that the if clause has some errors. I read this examples: http://books.zkoss.org/wiki/ZK_Developer's_Reference/UI_Composing/ZUML/EL_Expressions#Overview
But I dont understand whats wrong. I cannot put @load(vm.numCol) inside a EL?
You cannot mix "$" with "@". $ is evaluated once at page loading time. And "if" works only with "$".
It tries to interpret it as EL expression and "@load..." isn't.
Maybe (no idea if this works) you can play with "visible" attribute instead.
Thank you, I'll try.
And can I create a variable in zul? If so, i would be able to create a var inicialized with the @load(vm.numCol) and in the if statement I could see if the variable was >2 or >3. Is it possible?
The solution depends on the following questions:
- is the number of columns dynamic within page lifecycle
- where is this value set
Based on the answers it means:
- you can or cannot use "if"
- how you get the value, e.g. from ${param.numColumns}, ${arg.numColumns}, etc.
To your question: Of course you can define a variable in a <zscript> section and use it in "if". A lot of ZK demo examples do that (the definition).
But keep in mind that the superior solution is to use a composer or view model.
Asked: 2012-05-24 20:10:50 +0800
Seen: 156 times
Last updated: May 25 '12