ListView.Sort

Discuss GUI programming with the MUI Royale plugin here
djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

ListView.Sort

Post 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.
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: ListView.Sort

Post 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.
djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: ListView.Sort

Post 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...
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com
djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: ListView.Sort

Post 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.
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com
djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: ListView.Sort

Post by djrikki »

Date sorting isn't great either... Day 01 listed before 10.
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: ListView.Sort

Post 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.
djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: ListView.Sort

Post by djrikki »

Yes that would be cool, absolutely what I was recommending.
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: ListView.Sort

Post by airsoftsoftwair »

Will be added for next version.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: ListView.Sort

Post 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)
djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: ListView.Sort

Post 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
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com
Post Reply