I have a few dropdowns that I need to filter a list on, these dropdowns correlate to existing properties on a DocType. So the question is how in 4.5 and higher can I filter a select based on a variable?
Example - dropdown id = country, property alias = country ($filter). Selected value = 'Japan' ($text)
Sorry man, none of the above give me what I need - any other ideas? The only other way I can think of doing it is add another xsl:choose and then test against what the $filter variable is as doing something like country = $text as that works.
What I meant was - does the first one (just the key()) give you the nodes from which you need to select the final? If so, does adding the parentId filter narrow 'em down but still return the wanted node(s)? And so on and so forth...
Could you explain a little more about the scenario?
This is the one that selects the nodes I need - unfiltered. Then I have some dropdowns that then send querystrings back which I need to filter the list on i.e. $filter will be the property name and $text will be what I need to filter on (hope that made sense)
Thanks but what I need to do is decide on the property I want dynamically - rather than knowing that I want 'country' - could be one of about 5 properties I want to filter on.
Property via Variable
Hi All,
I have a few dropdowns that I need to filter a list on, these dropdowns correlate to existing properties on a DocType. So the question is how in 4.5 and higher can I filter a select based on a variable?
Example - dropdown id = country, property alias = country ($filter). Selected value = 'Japan' ($text)
<xsl:for-each select="$currentPage/* [$filter = $text]">
Is something like that possible? I'm sure you could do it in the old schema with /data [@alias=string($filter)]
TIA,
Adrian
Hi Adrian,
You're probably looking for the name() function:
If you need to selected based on the value too, do this:
/Chriztian
Hi Chriztian,
Doesnt seem to work (or output anything) -
Thanks,
Adrian
Hi Adrian,
Could easily be a mismatch with the key() - try checking every step of the expression until it doesn't give you the expected results:
/Chriztian
Chriztian,
Sorry man, none of the above give me what I need - any other ideas? The only other way I can think of doing it is add another xsl:choose and then test against what the $filter variable is as doing something like country = $text as that works.
Adrian
No worries Adrian,
What I meant was - does the first one (just the key()) give you the nodes from which you need to select the final? If so, does adding the parentId filter narrow 'em down but still return the wanted node(s)? And so on and so forth...
Could you explain a little more about the scenario?
/Chriztian
Chriztian,
This is the one that selects the nodes I need - unfiltered. Then I have some dropdowns that then send querystrings back which I need to filter the list on i.e. $filter will be the property name and $text will be what I need to filter on (hope that made sense)
Thanks,
Adrian
Adrian,
I did the following, this was written in the old schema, and I used on the online converter to create the new schema code:
Then add your match template to display each record.
Regards
Richard
Hi Richard,
Thanks but what I need to do is decide on the property I want dynamically - rather than knowing that I want 'country' - could be one of about 5 properties I want to filter on.
Adrian
BTW - If I do
<xsl:copy-ofselect="key('groupByName', name())[../@id = $centre/@id][country = $text"/>
It filters properly so the syntax is correct and the correct order. Just when trying to pass in dynamic properties it fails.
Adrian
Ah . OK :-)
This ouoghht to do it then:
Missed that it was a step further down :-)
/Chriztian
Chriztian,
That worked perfectly :) I did try something similar yesterday but syntax must of been off somewhere.
Once again you come to the rescue with your Ninja XSLT skills. I now owe you a few beers :)
Adrian
Why thank you!
Two words I like a lot... "few beers" :-)
/Chriztian
is working on a reply...