Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Saturday, November 23, 2024 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - Controls
Forum to discuss usage & tips for SalesLogix controls and other 3rd party ActiveX controls. View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to Controls | New ThreadView:  Search:  
 Author  Thread: Dynamic Sorting of a Listview
Alan Gates
Posts: 2
 
Dynamic Sorting of a ListviewYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Mar 07 11:45 AM
fiogf49gjkf0d
Does anyone have sample code that they would be willing to post showing me how to sort a listview when a user clicks a column header? I have the listview built but need to add the sort capablity. I am currently running Saleslogix V6.2.6

Thanks in advance!
Alan
[Reply][Quote]
Jeremy Brayton
Posts: 491
Top 10 forum poster: 491 posts
 
Re: Dynamic Sorting of a ListviewYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Mar 07 5:07 PM
fiogf49gjkf0d
I hate to say that I don't have an example for you but here's a secret to my ListView success: The Delphi TListView. SLX's control is essentially a wrapper around the delphi TListView control, so many of the same behaviors and programmatic differences are the same. The problem is if you don't know Delphi, it's not quite an easy translation into VBScript but it isn't hard to understand the "meat" you could say.

Here's an example for sorting a TListView (with HEAVY Delphi sprinkles): http://www.latiumsoftware.com/en/delphi/00011.php

The SLX ListView is a read-only control in that it does not have any bindable properties. That means if worst comes to shove, you can sort your data before importing it into the control. According to the example the SortType of stText could be used to sort the contents automatically. There's also the OnCompare event but there doesn't seem to be a CustomSort method in Intellisense (though there is an AlphaSort method).

So by combining the example here's what I've come up with:
1) Set a integerColumnIndex variable outside your events in your form, preferably at the very top
2) Set an OnColumnClick event handler. Set integerColumnIndex to Column.Index. Call ListView.AlphaSort.
3) Set an OnCompare event handler. if integerColumnIndex = 0, compare Item*.Caption, else compare Item*.SubItems(integerColumnIndex).Caption. *NOT COMPLETE*

Since OnCompare is a function, your return should be the better ListViewItem according to your sort order (asc/desc). The Delphi examples I've looked at don't do this so I'm guessing SLX is looking for the Item1 or Item2 variable but I could be wrong.
[Reply][Quote]
Jeremy Brayton
Posts: 491
Top 10 forum poster: 491 posts
 
Re: Dynamic Sorting of a ListviewYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Mar 07 5:22 PM
fiogf49gjkf0d
Argh, I should have explained the *NOT COMPLETE*. The examples I have cast the captions as strings, then use the internal Delphi CompareStr() function to return which string is greater.

What we'd do is cast the captions as strings, use the VBScript StrComp(string1, string2) function to determine which is greater, then return the corresponding ListViewItem to the function. In theory, that is how it should play out. I'm not too sure that'll work exactly as planned though with the big "what if" being ListViewCompare = Item1/Item2.
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 11/23/2024 3:10:39 AM