Sort listview on column click

Hi,

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

Thanks
Abhi
vjabhiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sajuksCommented:
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
vjabhiAuthor Commented:
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
sajuksCommented:
does GetColumn  help ?Can you post your srd file here. am too bored to create one to test.
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

vjabhiAuthor Commented:
just have simple question..
when i click on column ..
how i can know which column has been clicked in click event
0
gajender_99Commented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Vikas_DixitCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.