Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
20 replies
Subscribers
9 subscribers
Views
4156 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
General
Hi I have a scenario wherein I am displaying data in my drop down by
komalc3
A Score Level 1
over 9 years ago
Hi
I have a scenario wherein I am displaying data in my drop down by fetching the values from DB via. query rule or query entity. Now I want to display data in the drop down in a sorted form and I am not using sorting in my query rule or the a!sortInfo in the paginInfo of my a!query entity. Is there a way I can do it?
Thanks in advance.
OriginalPostID-208782
OriginalPostID-208782
Discussion posts and replies are publicly visible
0
Rahul Gundu
over 9 years ago
Go through below example, Using todatasubset() , a!pagingInfo() we can sort the query result.
load(
local!cdt_queryData:{
{name:"CBC",id:1},{name:"DBA",id:2},{name:"ABC",id:3},{name:"BBC",id:4}
},
local!sortedData:fn!todataSubset(local!cdt_queryData,a!pagingInfo(startIndex:1,batchSize:-1,sort:a!sortInfo(field:"name",ascending:true))),
a!dropdownField(
choiceLabels:index(local!sortedData.data,"name",{}),
choiceValues:index(local!sortedData.data,"id",{}),
placeholderLabel:"Select"
)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 9 years ago
@komal Hi, you can actually apply the todatasubset() over the obtained data from the query entity and in the todatasubset() you can give pagingInfo as per your wish.
Example:
todatasubset(
rule!myQueryEntity().data,
Paging info defined by a!pagingInfo() as desired by you.
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
komalc3
A Score Level 1
over 9 years ago
Hi rahulg262, sikhivahans
Thank you for your replies.
But my query is I don't want to use a!sortInfo in a!pagingInfo(). Without using this is there any way available to achieve sorted values in the drop down.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 9 years ago
Why don't you want to use it?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
komalc3
A Score Level 1
over 9 years ago
Hi stefanh791
It's just a curiosity that arose while working on a POC, nothing in particular!!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
komalc3
A Score Level 1
over 9 years ago
The sort in a!pagingInfo is what we generally use. Trying to find is there in other way to achieve the same goal.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 9 years ago
@komalc You can actually use sort() or reverse(sort()) as long as the choiceLabels and choiceValues are same but if both are different, it would be good to perform sort on the entire CDT data by using a datasubset or by applying the pagingInfo in the query rule or query entity, as this holds data together while performing sorting.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 9 years ago
AFAIK this is the options we have. Just recently I had a problem to sort just a list of strings. As this is no CDT pagingInfo cannot be used directly. So I created a small expression which creates an ad-hoc data structure. This way I can use pagingInfo in such cases.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 9 years ago
This is funny. I was sure there is a sort() but it is not visible here
forum.appian.com/.../Appian_Functions.html
or in the editor itself. My case was a bit more complex as I had to sort the strings but sort them by a modified version. So the original version goes to the choiceValues and the modified one to the choiceLabels.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 9 years ago
@stefanh Correct, as per my knowledge, that's actually a hidden function similar to wherecontains().
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
>