PDA

View Full Version : Fokus auf eine cWebList (von Mehreren)



Hook
5-Dec-2019, 01:06 AM
Guten Morgen zusammen,
ich lese ja schon seit geraumer Zeit hier im Forum mit und finde auch oft die entsprechenden Lösungsansätze.
Als "neuer Dataflexer" möchte ich nun hiermit auch aktiver das Forum nutzen :)

Ich habe eine Web-/Mobile Anwendung, in der je nach Ausrichtung des Bildschirms/Gerätes 7 cWebList nebeneinander (Querformat)
oder untereinander (Hochformat) dargestellt werden.

Mein Problem: Ich möchte im Hochformat den Fokus beim OnShow auf eine bestimmte Liste setzen,
klappt aber so nicht :confused:

folgende Zeilen habe ich am Ende der OnShow Procedure dafür vorgesehen:


If ((eMode NE rmDesktop) and (iAusrichtung EQ 0)) Begin //wenn Mobilgerät & Hochformat
//auf die Liste des aktuellen Wochentag springen
If (iDay EQ 1) Send Focus of oLiDay1
If (iDay EQ 2) Send Focus of oLiDay2
If (iDay EQ 3) Send Focus of oLiDay3
If (iDay EQ 4) Send Focus of oLiDay4
If (iDay EQ 5) Send Focus of oLiDay5
If (iDay EQ 6) Send Focus of oLiDay6
If (iDay EQ 7) Send Focus of oLiDay7
End


Wo liegt mein Fehler bzw. was muss ich beachten damit es funktioniert?

GhostShotIV
9-Dec-2019, 03:17 AM
Hallo Sebastian,

kann man da eine View haben mit der man das Problem nachvollziehen kann?

Mit dem Teil-Quelltext müsste man die View erst selbst aufbauen und einige Annahmen machen, wie das ganze aufgebaut ist.

Hook
9-Dec-2019, 09:03 AM
Habe mal versucht das Wesentliche als WebView zusammen zu kürzen,
hoffe das ist so hilfreicher für eine Lösungsfindung.



Use cWebView.pkg
Use cWebPanel.pkg
Use cWebButton.pkg
Use cWebForm.pkg
Use cWebList.pkg
Use cWebColumn.pkg
Use cWebColumnButton.pkg


Object oWochenuebersicht is a cWebView
Set psCaption to "Wochenübersicht"
Set pbFocusFirstOnShow to False
Set pbServerOnShow to True
Object oWebMainPanel is a cWebPanel
Set piColumnCount to 1

// die einzelnen Listen für 7 Tage
Object oLiTag1 is a cWebList
Set piColumnSpan to 1
Set pbDataAware to False
Set pbFillHeight to True
Set pbScroll to False
Set pbColumnSortable to False
Set pbServerOnRowClick to True

Object oWebColumn1 is a cWebColumn
Set psCaption to "Montag"
Set piWidth to 90
End_Object

Object oWebColumnButton12 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "detail"
End_Object

Object oWebColumnButton1 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "delete"
End_Object

Procedure OnManualLoadData tWebRow[] ByRef aTheRows String ByRef sCurrentRowID
Forward Send OnManualLoadData (&aTheRows) (&sCurrentRowID)
End_Procedure //OnManualLoadData oLiTag1

//Klick auf Zeile
Procedure OnRowClick String sRowID
Forward Send OnRowClick sRowID
End_Procedure //onRowClick LiTag1
End_Object //LiTag1


Object oLiTag2 is a cWebList
Set piColumnSpan to 1
Set piColumnIndex to 1
Set pbDataAware to False
Set pbFillHeight to True
Set pbScroll to False
Set pbColumnSortable to False
Set pbServerOnRowClick to True

Object oWebColumn2 is a cWebColumn
Set psCaption to "Dienstag"
Set piWidth to 90
End_Object

Object oWebColumnButton22 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "detail"
End_Object

Object oWebColumnButton2 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "delete"
End_Object

Procedure OnManualLoadData tWebRow[] ByRef aTheRows String ByRef sCurrentRowID
Forward Send OnManualLoadData (&aTheRows) (&sCurrentRowID)
End_Procedure //OnManualLoadData oLiTag2

//Klick auf Zeile
Procedure OnRowClick String sRowID
Forward Send OnRowClick sRowID
End_Procedure //onRowClick LiTag2
End_Object //LiTag2

Object oLiTag3 is a cWebList
Set piColumnSpan to 1
Set piColumnIndex to 2
Set pbDataAware to False
Set pbFillHeight to True
Set pbScroll to False
Set pbColumnSortable to False
Set pbServerOnRowClick to True

Object oWebColumn3 is a cWebColumn
Set psCaption to "Mittwoch"
Set piWidth to 90
End_Object

Object oWebColumnButton32 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "detail"
End_Object

Object oWebColumnButton3 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "delete"
End_Object

Procedure OnManualLoadData tWebRow[] ByRef aTheRows String ByRef sCurrentRowID
Forward Send OnManualLoadData (&aTheRows) (&sCurrentRowID)
End_Procedure //OnManualLoadData oLiTag3

//Klick auf Zeile
Procedure OnRowClick String sRowID
Forward Send OnRowClick sRowID
End_Procedure //onRowClick LiTag3
End_Object //LiTag3

Object oLiTag4 is a cWebList
Set piColumnSpan to 1
Set piColumnIndex to 3
Set pbDataAware to False
Set pbFillHeight to True
Set pbScroll to False
Set pbColumnSortable to False
Set pbServerOnRowClick to True

Object oWebColumn4 is a cWebColumn
Set psCaption to "Donnerstag"
Set piWidth to 90
End_Object

Object oWebColumnButton42 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "detail"
End_Object

Object oWebColumnButton4 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "delete"
End_Object

Procedure OnManualLoadData tWebRow[] ByRef aTheRows String ByRef sCurrentRowID
Forward Send OnManualLoadData (&aTheRows) (&sCurrentRowID)
End_Procedure //OnManualLoadData oLiTag4

//Klick auf Zeile
Procedure OnRowClick String sRowID
Forward Send OnRowClick sRowID
End_Procedure //onRowClick LiTag4
End_Object //LiTag4


Object oLiTag5 is a cWebList
Set piColumnSpan to 1
Set piColumnIndex to 4
Set pbDataAware to False
Set pbFillHeight to True
Set pbScroll to False
Set pbColumnSortable to False
Set pbServerOnRowClick to True

Object oWebColumn5 is a cWebColumn
Set psCaption to "Freitag"
Set piWidth to 90
End_Object

Object oWebColumnButton52 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "detail"
End_Object

Object oWebColumnButton5 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "delete"
End_Object

Procedure OnManualLoadData tWebRow[] ByRef aTheRows String ByRef sCurrentRowID
Forward Send OnManualLoadData (&aTheRows) (&sCurrentRowID)
End_Procedure //OnManualLoadData oLiTag5

//Klick auf Zeile
Procedure OnRowClick String sRowID
Forward Send OnRowClick sRowID
End_Procedure //onRowClick LiTag5
End_Object //LiTag5

Object oLiTag6 is a cWebList
Set piColumnSpan to 1
Set piColumnIndex to 5
Set pbDataAware to False
Set pbFillHeight to True
Set pbScroll to False
Set pbColumnSortable to False
Set pbServerOnRowClick to True

Object oWebColumn6 is a cWebColumn
Set psCaption to "Samstag"
Set piWidth to 90
End_Object

Object oWebColumnButton62 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "detail"
End_Object

Object oWebColumnButton6 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "delete"
End_Object

Procedure OnManualLoadData tWebRow[] ByRef aTheRows String ByRef sCurrentRowID
Forward Send OnManualLoadData (&aTheRows) (&sCurrentRowID)
End_Procedure //OnManualLoadData oLiTag6

//Klick auf Zeile
Procedure OnRowClick String sRowID
Forward Send OnRowClick sRowID
End_Procedure //onRowClick LiTag6
End_Object //LiTag6

Object oLiTag7 is a cWebList
Set piColumnSpan to 1
Set piColumnIndex to 6
Set pbDataAware to False
Set pbFillHeight to True
Set pbScroll to False
Set pbColumnSortable to False
Set pbServerOnRowClick to True

Object oWebColumn7 is a cWebColumn
Set psCaption to "Sonntag"
Set piWidth to 90
End_Object

Object oWebColumnButton72 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "detail"
End_Object

Object oWebColumnButton7 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "delete"
End_Object

Procedure OnManualLoadData tWebRow[] ByRef aTheRows String ByRef sCurrentRowID
Forward Send OnManualLoadData (&aTheRows) (&sCurrentRowID)
End_Procedure //OnManualLoadData oLiTag7

//Klick auf Zeile
Procedure OnRowClick String sRowID
End_Procedure //onRowClick LiTag7
End_Object //LiTag7

End_Object

//++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++ +++++


Procedure OnShow
Forward Send OnShow
DateTime dtDatum //Datum -> Heute
Integer iTag //Wochentag Mo=1, Di=2,...
Integer iAusrichtung //Bildschirmausrichtung -> 0 = Hochformat
Integer eMode //Modus, was für ein Gerätetyp

//Gerätetyp und Ausrichtung holen
Move 0 to iAusrichtung
WebGet peMode of ghoWebApp to eMode
Sysdate dtDatum //Heute

Move (DateGetDayOfWeekISO(dtDatum)) to iTag //Welcher Wochentag ist heute?

If ((eMode NE rmDesktop) and (iAusrichtung EQ 0)) Begin //wenn Mobilgerät & Hochformat
//auf die Liste des aktuellen Wochentag springen
If (iTag EQ 1) Send Focus of oLiTag1
If (iTag EQ 2) Send Focus of oLiTag2
If (iTag EQ 3) Send Focus of oLiTag3
If (iTag EQ 4) Send Focus of oLiTag4
If (iTag EQ 5) Send Focus of oLiTag5
If (iTag EQ 6) Send Focus of oLiTag6
If (iTag EQ 7) Send Focus of oLiTag7
End
End_Procedure //OnShow

End_Object //oWochenuebersicht

GhostShotIV
9-Dec-2019, 11:00 AM
Hallo Sebastian,

ich habe mal ein bisschen mit deinem Beispiel herum gespielt (kannte das pbScroll z.B. noch garnicht) und habe was zusammen gebastelt, das zeigt, dass es prinzipiell funktionieren sollte.


Use cWebView.pkg
Use cWebPanel.pkg
Use cWebButton.pkg
Use cWebForm.pkg
Use cWebList.pkg
Use cWebColumn.pkg
Use cWebColumnButton.pkg

Class cManualWebList is a cWebList
Procedure Construct_Object
Forward Send Construct_Object
Set pbDataAware to False
Set pbScroll to False
Set pbColumnSortable to False
Set pbServerOnRowClick to True
End_Procedure

Procedure OnLoad
Forward Send OnLoad
Send GridRefresh
End_Procedure
End_Class

Object oWochenuebersicht is a cWebView
Set psCaption to "Wochenübersicht"
Set pbFocusFirstOnShow to False
Set pbServerOnShow to True
Object oWebMainPanel is a cWebPanel
Set piColumnCount to 1

Function DummyData Returns tWebRow[]
tWebRow[] aTheRows

Move "1" to aTheRows[0].sRowId
Move "1" to aTheRows[0].aCells[0].sValue
Move "1" to aTheRows[0].aCells[1].sValue
Move "1" to aTheRows[0].aCells[2].sValue
Move "2" to aTheRows[1].sRowId
Move "2" to aTheRows[1].aCells[0].sValue
Move "2" to aTheRows[1].aCells[1].sValue
Move "2" to aTheRows[1].aCells[2].sValue

Function_Return aTheRows
End_Function

// die einzelnen Listen für 7 Tage
Object oLiTag1 is a cManualWebList
Set piColumnSpan to 1

Object oWebColumn1 is a cWebColumn
Set psCaption to "Montag"
Set piWidth to 90
End_Object

Object oWebColumnButton12 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "detail"
End_Object

Object oWebColumnButton1 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "delete"
End_Object

Procedure OnManualLoadData tWebRow[] ByRef aTheRows String ByRef sCurrentRowID
Forward Send OnManualLoadData (&aTheRows) (&sCurrentRowID)
Get DummyData to aTheRows
End_Procedure //OnManualLoadData oLiTag1

//Klick auf Zeile
Procedure OnRowClick String sRowID
Forward Send OnRowClick sRowID
End_Procedure //onRowClick LiTag1
End_Object //LiTag1


Object oLiTag2 is a cManualWebList
Set piColumnSpan to 1
Set piColumnIndex to 1

Object oWebColumn2 is a cWebColumn
Set psCaption to "Dienstag"
Set piWidth to 90
End_Object

Object oWebColumnButton22 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "detail"
End_Object

Object oWebColumnButton2 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "delete"
End_Object

Procedure OnManualLoadData tWebRow[] ByRef aTheRows String ByRef sCurrentRowID
Forward Send OnManualLoadData (&aTheRows) (&sCurrentRowID)
Get DummyData to aTheRows
End_Procedure //OnManualLoadData oLiTag2

//Klick auf Zeile
Procedure OnRowClick String sRowID
Forward Send OnRowClick sRowID
End_Procedure //onRowClick LiTag2
End_Object //LiTag2

Object oLiTag3 is a cManualWebList
Set piColumnSpan to 1
Set piColumnIndex to 2

Object oWebColumn3 is a cWebColumn
Set psCaption to "Mittwoch"
Set piWidth to 90
End_Object

Object oWebColumnButton32 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "detail"
End_Object

Object oWebColumnButton3 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "delete"
End_Object

Procedure OnManualLoadData tWebRow[] ByRef aTheRows String ByRef sCurrentRowID
Forward Send OnManualLoadData (&aTheRows) (&sCurrentRowID)
Get DummyData to aTheRows
End_Procedure //OnManualLoadData oLiTag3

//Klick auf Zeile
Procedure OnRowClick String sRowID
Forward Send OnRowClick sRowID
End_Procedure //onRowClick LiTag3
End_Object //LiTag3

Object oLiTag4 is a cManualWebList
Set piColumnSpan to 1
Set piColumnIndex to 3

Object oWebColumn4 is a cWebColumn
Set psCaption to "Donnerstag"
Set piWidth to 90
End_Object

Object oWebColumnButton42 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "detail"
End_Object

Object oWebColumnButton4 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "delete"
End_Object

Procedure OnManualLoadData tWebRow[] ByRef aTheRows String ByRef sCurrentRowID
Forward Send OnManualLoadData (&aTheRows) (&sCurrentRowID)
Get DummyData to aTheRows
End_Procedure //OnManualLoadData oLiTag4

//Klick auf Zeile
Procedure OnRowClick String sRowID
Forward Send OnRowClick sRowID
End_Procedure //onRowClick LiTag4
End_Object //LiTag4


Object oLiTag5 is a cManualWebList
Set piColumnSpan to 1
Set piColumnIndex to 4

Object oWebColumn5 is a cWebColumn
Set psCaption to "Freitag"
Set piWidth to 90
End_Object

Object oWebColumnButton52 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "detail"
End_Object

Object oWebColumnButton5 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "delete"
End_Object

Procedure OnManualLoadData tWebRow[] ByRef aTheRows String ByRef sCurrentRowID
Forward Send OnManualLoadData (&aTheRows) (&sCurrentRowID)
Get DummyData to aTheRows
End_Procedure //OnManualLoadData oLiTag5

//Klick auf Zeile
Procedure OnRowClick String sRowID
Forward Send OnRowClick sRowID
End_Procedure //onRowClick LiTag5
End_Object //LiTag5

Object oLiTag6 is a cManualWebList
Set piColumnSpan to 1
Set piColumnIndex to 5

Object oWebColumn6 is a cWebColumn
Set psCaption to "Samstag"
Set piWidth to 90
End_Object

Object oWebColumnButton62 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "detail"
End_Object

Object oWebColumnButton6 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "delete"
End_Object

Procedure OnManualLoadData tWebRow[] ByRef aTheRows String ByRef sCurrentRowID
Forward Send OnManualLoadData (&aTheRows) (&sCurrentRowID)
Get DummyData to aTheRows
End_Procedure //OnManualLoadData oLiTag6

//Klick auf Zeile
Procedure OnRowClick String sRowID
Forward Send OnRowClick sRowID
End_Procedure //onRowClick LiTag6
End_Object //LiTag6

Object oLiTag7 is a cManualWebList
Set piColumnSpan to 1
Set piColumnIndex to 6

Object oWebColumn7 is a cWebColumn
Set psCaption to "Sonntag"
Set piWidth to 90
End_Object

Object oWebColumnButton72 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "detail"
End_Object

Object oWebColumnButton7 is a cWebColumnButton
Set piWidth to 15
Set psBtnCssClass to "delete"
End_Object

Procedure OnManualLoadData tWebRow[] ByRef aTheRows String ByRef sCurrentRowID
Forward Send OnManualLoadData (&aTheRows) (&sCurrentRowID)
Get DummyData to aTheRows
End_Procedure //OnManualLoadData oLiTag7

//Klick auf Zeile
Procedure OnRowClick String sRowID
Forward Send OnRowClick sRowID
End_Procedure //onRowClick LiTag7
End_Object //LiTag7

End_Object

//++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++ +++++

Object oTimer is a cWebTimer
Procedure OnTimer
Handle hObj
Get FocusObject of ghoWebApp to hObj
Showln (Object_Label(hObj))
End_Procedure
End_Object

Procedure OnShow
Forward Send OnShow
DateTime dtDatum //Datum -> Heute
Integer iTag //Wochentag Mo=1, Di=2,...
Integer iAusrichtung //Bildschirmausrichtung -> 0 = Hochformat
Integer eMode //Modus, was für ein Gerätetyp

//Gerätetyp und Ausrichtung holen
Move 0 to iAusrichtung
WebGet peMode of ghoWebApp to eMode
Sysdate dtDatum //Heute

Move (DateGetDayOfWeekISO(dtDatum)) to iTag //Welcher Wochentag ist heute?

If ((eMode<>rmDesktop) and (iAusrichtung=0)) Begin //wenn Mobilgerät & Hochformat
//auf die Liste des aktuellen Wochentag springen
If (iTag=1) Send Focus of oLiTag1
If (iTag=2) Send Focus of oLiTag2
If (iTag=3) Send Focus of oLiTag3
If (iTag=4) Send Focus of oLiTag4
If (iTag=5) Send Focus of oLiTag5
If (iTag=6) Send Focus of oLiTag6
If (iTag=7) Send Focus of oLiTag7
End
End_Procedure //OnShow

End_Object //oWochenuebersicht

Das Problem dürfte aber eher sein, dass man es einer cWebList nicht ansehen kann, wenn sie den Fokus hat, oder Fokus ist nicht das was du eigentlich möchtest.

Das angepasste Beispiel bekommt von mir ein paar Werte in jede Liste rein geschrieben, damit man auch was sehen kann. Damit die cWebList Datensätze anzeigt, wenn sie im manuellen Modus ist, muss man ihr noch ein GridRefresh schicken, was ich in eine extra Klasse über der View ausgelagter habe (sowas sollte man normalerweise in eine separate Datei packen und die dann mit "Use" in die View ziehen, aber für das Beispiel funktioniert es auch so).
Ein WebTimer frägt dann regelmäßig ab, welches WebObjekt gerade den Fokus hat (mit "FocusObject") und gibt den Objektnamen aus (die Ausgabe kann man nur mit laufendem Debugger sehen, also nicht für effektiven Einsatz verwenden, sondern nur für Fehlersuche).
In der Ausgabe kann man dann auch sehen, dass das "Send Focus" funktioniert hat, da der Name der Liste ausgegeben wird, welcher Wochentag gerade auch immer aktuell sein sollte.

Die View scrollt auch zu Listen hin, die nicht im sichtbaren Bereich sind, so dass man diese dann auch sehen kann.
Aber wie gesagt, es ist nicht sichtbar, welche der Listen aktuell den Fokus haben. Dafür müsste/sollte man etwas per CSS machen.

Außerdem noch als Hinweis, verwende im Idealfall in If Vergleichen nicht "EQ", "NE" usw. Die sind mehr für Find und Constrain Befehle gedacht.
Es war zwar fürher üblich die auch für If Abfragen zu verwenden, aber sas ist stark veraltete Syntax. Dafür besser "=","<>" usw. verwenden (Hier (https://docs.dataaccess.com/dataflexhelp/mergedProjects/LanguageGuide/Expression_Syntax.htm) zu finden unter "Operators" und dann "Relational Operators")

Hilft dir das weiter, oder bin ich voll am Ziel vorbei geschossen?

Hook
10-Dec-2019, 02:01 AM
habe nun meine Ansicht mit deinen Vorschlägen umgestellt,
...und es funktioniert. Danke für deine Hilfe



Außerdem noch als Hinweis, verwende im Idealfall in If Vergleichen nicht "EQ", "NE" usw. Die sind mehr für Find und Constrain Befehle gedacht.
Es war zwar fürher üblich die auch für If Abfragen zu verwenden, aber sas ist stark veraltete Syntax. Dafür besser "=","<>" usw. verwenden (Hier (https://docs.dataaccess.com/dataflexhelp/mergedProjects/LanguageGuide/Expression_Syntax.htm) zu finden unter "Operators" und dann "Relational Operators")


Bin nun erst seit paar Monaten in Dataflex aktiv, und habe mich bisher oft an Sachen aus "alten" oder Forums-Quelltext bedient.
Daher auch Danke für diesen Hinweis, werde versuchen an mir zu arbeiten und dies so für die Zukunft umzusetzen ;-)

Matthias
10-Dec-2019, 02:58 AM
Noch ein Hinweis: Der Quellcode sieht mir wie eine Kalenderfunktionalität aus. Data Access bietet eine Wrapper Klasse für einen "richtigen" Kalender basierend auf dem dHtmlx Scheduler an. Wir haben den seit einiger Zeit im Einsatz und sind sehr zufrieden mit der Funktionalität. Auch das Responsive Design funktioniert von alleine.

Hier der Link mit den Infos:
https://www.dataaccess.eu/resources/downloads/download-category/download-subcategory-842?dagapsg=78