Code: Select all
ElseIf(msg.attribute = "SortColumn")
If(msg.triggervalue = 3)
moai.set("lvTankstellen","SortColumn",3, "nonotify", True)
moai.set("lvTankstellenHidden","SortColumn",3)
ElseIf(msg.triggervalue = 4)
moai.set("lvTankstellen","SortColumn",4, "nonotify", True)
moai.set("lvTankstellenHidden","SortColumn",4)
EndIf()
I started to test for a simplier solution like this:
Code: Select all
@REQUIRE "RapaGUI"
moai.CreateApp([[<?xml version="1.0" encoding="utf-8"?>
<application id="app">
<window title="ListviewStack" height="Screen:60" width="Screen:60">
<vgroup>
<vgroup frame="true" id="ListTankstellen" title="Tankstellenliste" weight="900">
<listview id="lvTankstellen" notify="doubleclick;ClickColumn;SortColumn" alternate="true">
<column title="Marke"/>
<column title="offen" checkbox="true"/>
<column title="Adresse"/>
<column title="Preis" sortable="true" notify="sortorder" id="lvTankstellenPreis"/>
<column title="Entfernung" sortable="true" notify="sortorder" id="lvTankstellenEntf"/>
</listview>
</vgroup>
<vgroup frame="true" id="ListTankstellenHidden" weight="900">
<listview id="lvTankstellenHidden">
<column title="Marke"/>
<column title="offen" checkbox="true"/>
<column title="Adresse"/>
<column title="Preis" sortable="true" id="lvTankstellenPreisHidden"/>
<column title="Entfernung" sortable="true" id="lvTankstellenEntfHidden"/>
<column title="lat" />
<column title="long" />
</listview>
</vgroup>
</vgroup>
</window>
</application>
]])
Function p_EventFunc(msg)
Switch msg.action
Case "RapaGUI":
Switch msg.id
Case "blabla":
Default:
If StartsWith(msg.id, "lvTankstellen") Then p_HandleListview(msg)
EndSwitch
EndSwitch
EndFunction
Function p_PrepareData()
moai.DoMethod("lvTankstellen", "Clear")
moai.DoMethod("lvTankstellenHidden", "Clear")
moai.Set("ListTankstellen","Hide",False)
For Local i = 0 To 3
moai.DoMethod("lvTankstellen", "Insert",i,i,i,i, i, i)
moai.DoMethod("lvTankstellenHidden", "Insert",i,i,i,i, i, i,i,i)
Next
moai.DoMethod("lvTankstellen", "Sort")
moai.DoMethod("lvTankstellenHidden", "Sort")
EndFunction
function p_HandleListview(msg)
If HaveItem(msg,"attribute")
If msg.attribute = "SortOrder"
moai.Set(msg.id .. "Hidden", "SortOrder", msg.TriggerValue)
moai.Set("lvTankstellenHidden", "SortColumn", 0) ; A work-around because the following line doesn't do anything.
;moai.DoMethod("lvTankstellenHidden", "Sort")
ElseIf msg.attribute = "DoubleClick"
p_ViewGasStationDetails()
ElseIf msg.attribute = "SortColumn"
moai.Set("lvTankstellenHidden", "SortColumn", msg.TriggerValue)
Else
DebugPrint("!!!", msg.attribute)
EndIf
EndIf
EndFunction
InstallEventHandler({RapaGUI = p_EventFunc})
p_PrepareData()
Repeat
WaitEvent
Forever
Andreas, do you think the Listview.Sort should work when used like this?
Code: Select all
@REQUIRE "RapaGUI"
moai.CreateApp([[<?xml version="1.0" encoding="utf-8"?>
<application id="app">
<window title="ListviewStack" height="Screen:60" width="Screen:60">
<vgroup>
<vgroup frame="true" id="ListTankstellen" title="Tankstellenliste" weight="900">
<listview id="lvTankstellen" alternate="true">
<column title="Marke"/>
<column title="offen" checkbox="true"/>
<column title="Adresse"/>
<column title="Preis" sortable="true" id="lvTankstellenPreis"/>
<column title="Entfernung" id="lvTankstellenEntf"/>
</listview>
</vgroup>
</vgroup>
</window>
</application>
]])
Function p_PrepareData()
moai.DoMethod("lvTankstellen", "Clear")
For Local i = 0 To 3
moai.DoMethod("lvTankstellen", "Insert",i,i,i,i, i, i)
Next
moai.Set("lvTankstellenPreis", "SortOrder", "Descending")
; This doesn't sort the list to the Descending order set above.
moai.DoMethod("lvTankstellen", "Sort")
Wait(100)
; Have to kick some other action on the list to get it sorted.
moai.Set("lvTankstellen", "SortColumn", 0)
moai.Set("lvTankstellen", "SortColumn", 3)
EndFunction
p_PrepareData()
Repeat
WaitEvent
Forever