ListviewColumn Sortable="0"

Discuss GUI programming with the RapaGUI plugin here
SamuraiCrow
Posts: 475
Joined: Fri May 15, 2015 5:15 pm
Location: Waterville, Minnesota USA

ListviewColumn Sortable="0"

Post by SamuraiCrow »

When I looked at the documentation for the sortable attribute, there appears to be no way to switch which column is sorted. Also, it's listed as being a number!? What values go to which behavior? Currently setting sortable to 0 in column 3 sorts by the first column. Sorting by any other positive value is stuck on the column it is selected in (column 3 in this case). Is there any way I can change the default column to sort, preferably by clicking the column title?
I'm on registered MorphOS using FlowStudio.
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: ListviewColumn Sortable="0"

Post by airsoftsoftwair »

SamuraiCrow wrote: Mon Nov 16, 2020 2:29 am When I looked at the documentation for the sortable attribute, there appears to be no way to switch which column is sorted. Also, it's listed as being a number!?
Yes, that's clearly a typo. Type should be boolean instead. I'll fix that.
What values go to which behavior? Currently setting sortable to 0 in column 3 sorts by the first column. Sorting by any other positive value is stuck on the column it is selected in (column 3 in this case). Is there any way I can change the default column to sort, preferably by clicking the column title?
Clicking the column title to sort might not work on all platforms but it should be possible to manually change the sorting column by setting Listviewcolumn.Sortable appropriately. Have you tried that?
SamuraiCrow
Posts: 475
Joined: Fri May 15, 2015 5:15 pm
Location: Waterville, Minnesota USA

Re: ListviewColumn Sortable="0"

Post by SamuraiCrow »

airsoftsoftwair wrote: Fri Nov 20, 2020 10:48 pm Yes, that's clearly a typo. Type should be boolean instead. I'll fix that.

Clicking the column title to sort might not work on all platforms but it should be possible to manually change the sorting column by setting Listviewcolumn.Sortable appropriately. Have you tried that?
Thanks for fixing the docs. I suppose I could give each column an id field and clear the original field, set the new one and sort the listview again.
I'm on registered MorphOS using FlowStudio.
amyren
Posts: 352
Joined: Thu May 02, 2019 11:53 am

Re: ListviewColumn Sortable="0"

Post by amyren »

Did you manage to make a way to change the sortable column?
If so, could you post an example of how to do it. I am currently using the Dialogs example as a base for a program, so an example based on that would be great.
SamuraiCrow
Posts: 475
Joined: Fri May 15, 2015 5:15 pm
Location: Waterville, Minnesota USA

Re: ListviewColumn Sortable="0"

Post by SamuraiCrow »

I didn't try yet. I kept running into various bugs in RapaGUI and have been hoping the new release version 2.0 would be out soon.
I'm on registered MorphOS using FlowStudio.
amyren
Posts: 352
Joined: Thu May 02, 2019 11:53 am

Re: ListviewColumn Sortable="0"

Post by amyren »

Thanks for the reply. Lets see then, one can hope that 2.0 have a solution for having muliple columns sortable.
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: ListviewColumn Sortable="0"

Post by airsoftsoftwair »

SamuraiCrow wrote: Tue Apr 13, 2021 4:23 am I didn't try yet. I kept running into various bugs in RapaGUI and have been hoping the new release version 2.0 would be out soon.
It sure will. It's next on the agenda.
davec
Posts: 21
Joined: Thu Sep 03, 2020 10:39 pm

Re: ListviewColumn Sortable="0"

Post by davec »

Hi,
I too am wondering about changing the sorting column when clicking on the column title.
For whatever reason, I cannot work out how to use Listview.column.Sortable.

Any examples would be greatly appreciated.

Dave
amyren
Posts: 352
Joined: Thu May 02, 2019 11:53 am

Re: ListviewColumn Sortable="0"

Post by amyren »

I did some try/error on this.
I found that there is no Event called when the column titles are clicked.
The "ClickColumn" attribute is only triggered when clicking at one of the items in the listview.
Is this a bug?

I made a log of the (msg) passed to EventFunc
Here is what happens when clicking in the listview at item number 6 down in the list, at column number 5
As you see by the timestamp, these two events happens at the same time.

Code: Select all

	{
		"action": "RapaGUI",
		"triggervalue": 4,
		"id": "lv",
		"class": "Listview",
		"attribute": "ClickColumn",
		"timestamp": 191.52494049072266
	},
	{
		"action": "RapaGUI",
		"triggervalue": 5,
		"id": "lv",
		"class": "Listview",
		"attribute": "Active",
		"timestamp": 191.52494049072266
	}
But I still struggle to find the command that will set the cloumn as sortable. The lack of examples sometimes makes RapaGUI into a guessing game for for non-experts.
amyren
Posts: 352
Joined: Thu May 02, 2019 11:53 am

Re: ListviewColumn Sortable="0"

Post by amyren »

Figured it out eventually.
I am now able to change the sorting column to any column I want. But note that you need to click somewhere in the list, at a column in a not-active entry to change the sorting column.

First give all the columns an id in the xml file so that there is an unique moai object to call for each column you want to be able to set sortable.
example:

Code: Select all

			<listview id="lv" notify="active">
				<column id="lv1col0" title="Lastname"/>
				<column id="lv1col1" title="Firstname" editable="true" />
				<column id="lv1col2" title="Phone" />
			</listview>	
Then in the evenfunc

Code: Select all

Function p_EventFunc(msg)
	Switch msg.action
	Case "RapaGUI":
		Switch msg.attribute
		Case "ClickColumn"
			Switch msg.id
			Case "lv"
				If msg.triggervalue=0 Then moai.Set("lv1col0", "sortable", True)
				If msg.triggervalue=1 Then moai.Set("lv1col1", "sortable", True)
				If msg.triggervalue=2 Then moai.Set("lv1col2", "sortable", True)
			Case "lv2"
				If msg.triggervalue=0 Then moai.Set("lv2col0", "sortable", True)
				If msg.triggervalue=1 Then moai.Set("lv2col1", "sortable", True)
				If msg.triggervalue=2 Then moai.Set("lv2col2", "sortable", True)
			EndSwitch
		EndSwitch
	EndSwitch
EndFunction
I have two listviews in my program, thats why the extra swicth to determine which listview that was clicked. If there is only one listview I guess the swicth msg.id part can be skipped.
Post Reply