[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Sort listview on column click

Posted on 2004-11-30
9
Medium Priority
?
576 Views
Last Modified: 2013-12-26
Hi,

i am using listview as report.
How can i sort listview based on column click.

Thanks
Abhi
0
Comment
Question by:vjabhi
6 Comments
 
LVL 33

Expert Comment

by:sajuks
ID: 12713668
did you check the help file ?
   listviewname.Sort ( sorttype, { column } )
That didnt help you ?

Try using userdefined! as the sorttype, and put your sort logic in the Sort event.
Alternatively are you using pfc then you could inherit from  u_lvs( it uses a datastore , so sort is default included)
0
 

Author Comment

by:vjabhi
ID: 12713717
i have see...
so i can write in column click...
listviewname.Sort ( sorttype, { column } )

But ewhat value to pass for column??
how do i get which column is clicked??
0
 
LVL 33

Expert Comment

by:sajuks
ID: 12713795
does GetColumn  help ?Can you post your srd file here. am too bored to create one to test.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:vjabhi
ID: 12713840
just have simple question..
when i click on column ..
how i can know which column has been clicked in click event
0
 
LVL 8

Accepted Solution

by:
gajender_99 earned 200 total points
ID: 12715054
declare
string  is_sort as instance varabile

and on datawindow click event paste this syntax


string      ls_col, ls_sort
integer      li_pos

SetPointer(HourGlass!)

/*******************************************************/
/* Get the name of the object the pointer is over.     */
/*******************************************************/
ls_col = this.GetObjectAtPointer()

/*******************************************************/
/* Get the tab position                                                              */
/*******************************************************/
li_pos = Pos(ls_col, "~t")

/*******************************************************/
/* Check last 2 characters                                                        */
/*******************************************************/
ls_col = Left(ls_col, li_pos - 1)

/*******************************************************/
/* if not a column heading, then return                                */
/*******************************************************/
if NOT Lower(Right(ls_col, 2)) = "_t" then Return

/*******************************************************/
/* Assumed that heading name is column name + "_t".       */
/* Remove the last to characters to get the column        */
/* name and then sort by it. If the sort criteria             */
/* matches the previous sort, then reverse it.                   */
/*******************************************************/
ls_col  = Left(ls_col, Len(ls_col) - 2)
ls_sort = ls_col + " A"

if ls_sort = is_sort then
      ls_sort = ls_col + " D"
else
      ls_sort = ls_col + " A"
end if

is_sort = ls_sort

this.SetSort(is_sort)
this.Sort()
0
 
LVL 8

Expert Comment

by:Vikas_Dixit
ID: 12719054
Hi,

There's a columnclick() event available with listviews, that display in report mode and buttonheader property is set to yes. The index of the column clicked is available as an argument.
So you can Just write following in the columnclick event:

Sort ( sorttype, column  )

See the help of columnclick event.

Regards,
Vikas Dixit
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deletiā€¦
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question