Hello Jonathan,
I had to tackle this problem a month or so ago. The
function you are using "ListView_ColumnClick" passes the column number
to this subroutine. I just 'shifted' it to a variable (See my example
below). In my table all my items we stored in a hash. Each value was
a list of comma delimited text. I simply created a new hash with the
same keys, but the new hash values only had items from the column that
was click on. It sounds compilcated, but it works. Without knowing how
your data is stored I can't really give you a 'working' example. I
included sections of my code to give you a better idea of what I did.
I hope this helps... if you have questions just fire them on back.
Cheers.
Perl Code Below
=============================
#----------------------------------------------------------
sub ListView_ColumnClick {
my $col = shift;
print "You click on column number $col\n";
my %sortonly = &NewList($col,%data); ## %data is a global variable
&SortListItem(/%data,/%sortonly);
}
#----------------------------------------------------------
sub SortListItem {
my ($data,$sortonly,$section) = @_;
my $check;
my %data = %$data;
my %sortonly = %$sortonly;
$check .= "$_" foreach (values %sortonly); ## Merge all values into 1 string
if ($check =~ /[a-z]|[A-Z]/g) { ##--> Compare Num or by Char depending in
%sortonly values
print "Text Compare!\n";
foreach (sort { $sortonly{$a} cmp $sortonly{$b} } keys %sortonly) {
## Code in here needs to clear the current View
## and then add items all over again. Just like
## you did when you first created it
## Use the keys that are stored in $_, but get the values
## from the original hash(in this case %data)
}
} else {
print "Number Compare\n";
foreach (sort { $sortonly{$b} <=> $sortonly{$a} } keys %sortonly) {
## Code in here needs to clear the current View
## and then add items all over again. Just like
## you did when you first created it.
## Use the keys that are stored in $_, but get the values
## from the original hash(in this case %data)
}
}
}
#----------------------------------------------------------
sub NewList {
## This creates another hash to use only for sorting purposes.
my ($col,%sortonly) = @_;
my $sortthis;
print "Sorting Using Col#: $col\n";
foreach (keys %sortonly) {
my @info = split /,/, $sortonly{$_};
$sortthis = $info[$col];
print "Sorting These Items: $sortthis\n";
$sortonly{$_} = "$sortthis";
}
return(%sortonly);
}
Monday, April 24, 2000, 09:16:57, you wrote:
JS> Well I figured out how to capture the column click but I don't know how to
JS> tell which one was clicked. As far as the sorting goes I think you have to
JS> write your own routine to sort the items and write them back to the listview
JS> but I could be wrong.
JS> To capture the event:
JS> sub ListView_ColumnClick {
JS> [code in here]
JS> }
JS> So how do I determine exactly what column was clicked?
JS> Jonathan
JS> --------------------------------------------------------------
JS> Jonathan Southwick [EMAIL PROTECTED]
JS> Technical and Network Services
JS> Allegheny College
JS> Meadville, PA 16335 814-332-2755
--
Best regards,
Cam mailto:[EMAIL PROTECTED]
__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com