Welcome to the IBM Collaboration Solutions Community IQJam.
UsernamePassword
Reset Password | Register
   
Home | Leader Board | Tags | Help
How can I add sort options to a Data Table control? 
I have a Data Table control binded to a Notes view and I want to allow users sorting column header.

Any example available out there?
Domino Development / XPages
Tagged
Pablo Solano - about 1 year ago |  |  | Viewed 345 times

There are 5 answers

2votes
Marked as correct on1/13/11 1:50 PM
I made a demo a while back with three ways to build a search interface with sortable columns. It might be of interest to you..
 
 
If the view has a lot of data (more than a thousand entries), you're probably better of setting the columns sortable in the notes view/using a view panel. The reason is that the methods used in blogpost are quite resource hungry (CPU/memory).


Tommy Valand - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


0votes
Thanks Tommy,
 
I used your implementation with a few variations:

1. I use db.FTSearch
2. Instead of text field for search criteria, I use a few combobox for criteria selection(Division, Originator, Description and Status)
 
I had problems with the array field definition, specifically with the "formula" type since it only allows simple funcions like @Created, @Modified. Sometimes you need a @if on there. What I did was to compute the formula in the computed field on Data table control.
 
The only issue I see with this approach is that sorting is done on the data you have on screen; for example: You are on page 1 of 5 and you sort by Date everything works fine, but if you are on Page 2 and you try to sort using a different  column then sorting is done on that page; it should go to page 1 and make the sort from there.
 
 
Thanks for sharing this elegant solution.

Pablo


Pablo Solano - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


1votes
The field definitions accepts any formula, but you have to escape the "string characters", or the evaluate will fail.
 
Regarding sorting, if you haven't already figured it out:
getComponent( 'viewComponentId' ).setFirst(0); 
 
Add the above line to the sort-code, and the view will go to the start. 


Tommy Valand - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


0votes
Thanks again,
 
 This line of code make it work.
 
getComponent( 'TemplatedSearch' ).setFirst(0);
toggleSortOrder( 'creationdate' )
 
Where do you find information/examples about these methods?


Pablo Solano - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


0votes
Regarding information, I use my XPages API Inspector. You can download it from OpenNTF.
 
When I made the demoapp, there wasn't much information available, so I had to experiment on my own. To make it easier to understand the XPages API, I made the Inspector.
 
There's also an API overview provided by IBM that you can take a look at. 
 
I updated my demoapp with some improvements today. One of them being the "go to first page on resort". You might want to take a look at it, as there are.


Tommy Valand - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community