Page 1 of 3

ListView.Sort

Posted: Mon Mar 25, 2013 8:36 pm
by djrikki
Hello,

In a listview with multiple columns .Sort seems to sort the listview erratically. In any case I was hoping this method would allow me to specify which column to sort content by, but it currently does not seem to allow for this.

Re: ListView.Sort

Posted: Wed Mar 27, 2013 5:46 pm
by airsoftsoftwair
This is a bug as well. It's fixed now and Listview.Sort also accepts a new argument now which allows you to specify the column index according to which the list view should be sorted.

Re: ListView.Sort

Posted: Sat May 10, 2014 2:52 pm
by djrikki
Still doesn't appear to be working, also the method of sorting needs to selectable or the developer can write their own custom sort.

A-Z
Z-A
0-9
9-A
Date sorting
Etc...

Re: ListView.Sort

Posted: Sat May 10, 2014 3:26 pm
by djrikki
Experiencing mixed-success with this atm, I think tags are getting the way as well of the sort.

Certainly need a way to reverse-sort.

Re: ListView.Sort

Posted: Sat May 10, 2014 3:50 pm
by djrikki
Date sorting isn't great either... Day 01 listed before 10.

Re: ListView.Sort

Posted: Sun May 11, 2014 2:43 pm
by airsoftsoftwair
Well, yeah, this is just how MUI's default sorting algorithm works. For fine-tuned sort control I'd need to add support for custom sorting through a callback function. Might be a useful enhancement for your needs.

Re: ListView.Sort

Posted: Sun May 11, 2014 4:06 pm
by djrikki
Yes that would be cool, absolutely what I was recommending.

Re: ListView.Sort

Posted: Thu May 15, 2014 10:59 pm
by airsoftsoftwair
Will be added for next version.

Re: ListView.Sort

Posted: Thu May 22, 2014 5:41 pm
by airsoftsoftwair
- New: Added Listview.SortFunc attribute; this allows you to specify a custom callback function
that will be called whenever your listview requires sorting; this allows you to customize
listview sorting, e.g. implement reverse alphabetical sorting or sorting by other customized
criteria (requested by Richard Lake)

Re: ListView.Sort

Posted: Sun Jul 06, 2014 12:13 pm
by djrikki
Firstly, thanks for 1.2 - however hitting a problem atm, I think I have the implementation correct, but only partial arguments are being sent to the callback function, a table representing Entry1 - which I am unable to debugprint the first element. Any light you can shed?

GUI Block:

Code: Select all

					<vgroup title="Search" disabled="true" id="searchresults-pagetab">
						<listview id="appstore-search-results" cyclechain="1" minlineheight="40" notify="active;titleclick;sortfunc">
							<column title="Title" minwidth="35"/>
							<column title="Category" minwidth="23"/>
							<column title="Version" minwidth="10"/>
							<column title="Size" minwidth="10"/>
							<column title="Rating" minwidth="18"/>
							<column hidden="true"/>
							<column hidden="true"/>
							<column hidden="true"/>
						</listview>
					</vgroup>
Event Block:

Code: Select all

	   	    Case "TitleClick"
	   	    If msg.id ="news-list" and msg.triggervalue = 0
	   	        ;ignore column 1 in the news-list listview
	   	    Else
		    	mui.DoMethod(msg.id,"Sort",msg.triggervalue)
		   	EndIf
Call Back Function:

Code: Select all

Function ListViewSort(a,b,column)
	
	debugprint(a) ; OUTPUTS typical table: Table: 0x54ce5df8
	debugprint(b) ; OUTPUTS Nil
	debugprint(column) ; OUTPUTS Nil
	
	debugprint(a[0]) ; Instead of Outputing first string element of the table it outputs nothing

    Return(value)
EndFunction