-
1 Attachment(s)
Selection popup
Hi,
I want to build a popup message with a selection list with the use of "ShowMessageBox".
In the help is a example of "ShowYupNopeNevermind" that allows you to augment the button(s) text.
In my case, I need to add a selection list (manually filled by an array) that the user can select one item from and confirm his selection.
I am not sure on where to start. Any help would be appreciated.
The Example image below shows the selection i had build in a native android app.
[ATTACH=CONFIG]11408[/ATTACH]
-
Re: Selection popup
Hi Benjamin,
Here is an example panel that shows how it could be done.
[CODE]Use cWebModalDialog.pkg
Use cWebList.pkg
Use cWebColumn.pkg
Use cWebHorizontalLine.pkg
Use cWebHtmlBox.pkg
Object oPanelSingleSelectorFromArray is a cWebModalDialog
Set piHeight to 299
{WebProperty=Server}
Property String[] wpaSelections
{WebProperty=Server}
Property String wpsDefault
Set pbServerOnShow to True
Procedure OnShow
Forward Send OnShow
Send GridRefresh of oWebList1
End_Procedure
Object oWebList1 is a cWebList
Set pbDataAware to False
Set pbServerOnRowClick to True
Procedure OnRowClick String sRowID
Send Ok
End_Procedure
Object oWebColumn1 is a cWebColumn
Set psCaption to "column"
Set piWidth to 50
End_Object
Procedure OnManualLoadData tWebRow[] ByRef aTheRows String ByRef sCurrentRowID
Integer iMax iItem
String sDefault
String[] aValues
WebGet wpaSelections of (ViewObject(Self)) to aValues
WebGet wpsDefault of (ViewObject(Self)) to sDefault
Move (SizeOfArray(aValues)-1) to iMax
For iItem from 0 to iMax
Move aValues[iItem] to aTheRows[iItem].sRowId
Move aValues[iItem] to aTheRows[iItem].aCells[0].sValue
Loop
If (sDefault<>"") Begin
Move sDefault to sCurrentRowID
End
End_Procedure
End_Object
Procedure PopupArraySelect Integer hReturnObject String[] aValues String sDefault String sCaption
WebSet psCaption to sCaption
WebSet wpaSelections to aValues
WebSet wpsDefault to sDefault
Send Popup hReturnObject
End_Procedure
Procedure GetDialogResult String ByRef sValue
WebGet psCurrentRowId of oWebList1 to sValue
End_Procedure
End_Object[/CODE]
That in turn may be called from a button (in another panel) like this:
[CODE] Object oWebButton1 is a cWebButton
Set psCaption to "Test"
Set piColumnIndex to 8
Set piColumnSpan to 2
Procedure OnClick
String[] aValues
Move "North" to aValues[0]
Move "East" to aValues[1]
Move "South" to aValues[2]
Move "West" to aValues[3]
Send PopupArraySelect of oPanelSingleSelectorFromArray Self aValues "South" "Choose direction"
End_Procedure
Procedure OnCloseModalDialog Handle hoModalDialog
String sResult
If (hoModalDialog=oPanelSingleSelectorFromArray) Begin
Send GetDialogResult of oPanelSingleSelectorFromArray (&sResult)
Send ShowInfoBox sResult "Selected item"
End
End_Procedure
End_Object
[/CODE]
I hope this gets you started. :-)
-Sture
-
3 Attachment(s)
Re: Selection popup
Thank you very much for this. With this, I got it working in no time.
I have another anomaly with sizing the dialog. Maybe a bug but I am not sure if I am doing something wrong.
When adding another column to the grid inside the dialog the WebApp Designer shows the change properly but when compiling and running it, the dialog appears as a small square box in the top left of the browser.
You can't click either close or the confirm button. See pictures for visuals.
[ATTACH=CONFIG]11468[/ATTACH][ATTACH=CONFIG]11467[/ATTACH]
I have added my source code below to share and reference for aboves issue.
SelectionDialog.wo
[CODE]
Object oSelectionListDialog is a cWebModalDialog
Set psCaption to "Select Item from list"
Set pbResizable to True
Set piMinHeight to 300
Set piMinWidth to 300
{WebProperty=True}
Property tListItem[] paListItems
{WebProperty=True}
Property Integer piSelectionIdno
// send reply on Esc or "x" as submit, which will send the callback on a cancel
Set pbServerOnEscape to True
Procedure OnEscape
Forward Send OnEscape
End_Procedure
Set pbServerOnShow to True
Procedure OnShow
Send GridRefresh of oSelectionItems
Forward Send OnShow
End_Procedure
Object oMainPanel is a cWebPanel
Set peRegion to prCenter
Set pbFillHeight to True
Set piHeight to 200
Object oSelectionItems is a cWebList
Set pbDataAware to False
Set pbShowHeader to False
Set piHeight to 120
Set pbFillHeight to True
Procedure OnManualLoadData tWebRow[] ByRef aTheRows String ByRef sCurrentRowID
Integer i iItemCount
tListItem[] aListItem
WebGet paListItems of oSelectionListDialog to aListItem
Forward Send OnManualLoadData (&aTheRows) (&sCurrentRowID)
Move (SizeOfArray(aListItem)-1) to iItemCount
For i from 0 to iItemCount
Move aListItem[i].iUniqueRecIdno to aTheRows[i].sRowID
Move aListItem[i].sDescription to aTheRows[i].aCells[0].sValue
Loop
Move 0 to sCurrentRowID
End_Procedure
Procedure OnLoad
Forward Send OnLoad
Send GridRefresh
End_Procedure
Procedure OnShow
Forward Send OnShow
End_Procedure
Object oDiscriptionWebColumn is a cWebColumn
Set psCaption to "Description"
Set piWidth to 50
Set pbFillHeight to True
End_Object
Object oDetailWebColumn is a cWebColumn
Set psCaption to "Detail"
Set pbNewLine to True
Set piWidth to 100
Set psCSSClass to "RowCaption"
End_Object
End_Object
End_Object
Object oButtonPanel is a cWebPanel
Set peRegion to prBottom
Set piColumnCount to 4
Object oConfirmBtn is a cWebButton
Set pbShowLabel to False
Set psCaption to "Confirm"
Set piColumnSpan to 4
Procedure OnClick
Send Ok
End_Procedure
End_Object
End_Object
Set pbServerOnSubmit to True
Procedure OnSubmit
Send Ok
End_Procedure
Procedure Ok
Integer iSelectionIdno
WebGet psCurrentRowID of oSelectionItems to iSelectionIdno
WebSet piSelectionIdno of oSelectionListDialog to iSelectionIdno
Forward Send Ok
End_Procedure
Procedure InitializeSelectionListDialog String sTitle Integer iWidth Integer iHeight tListItem[] aListItems
String sSelected
Move 0 to sSelected
WebSet piWidth of oSelectionListDialog to iWidth
WebSet piHeight of oSelectionListDialog to iHeight
WebSet paListItems of oSelectionListDialog to aListItems
WebSet psCaption of oSelectionListDialog to sTitle
End_Procedure
Procedure GetSelectedItem Integer ByRef iSelectionIdno Boolean ByRef bCancel
WebGet piSelectionIdno of oSelectionListDialog to iSelectionIdno
WebGet pbCanceled to bCancel
End_Procedure
End_Object
[/CODE]
Call from webview:
[CODE]
//ToDo: Build and pop up selection list to client.
Send InitializeSelectionListDialog of oSelectionListDialog "Select Attachment ..." 300 400 aAttachmentArray
Send Popup of oSelectionListDialog Self
[/CODE]
-
Re: Selection popup
Good, you're on track.
Don't set pbFillHeight of the first cWebColumn (it delegates to the list that already has it set) and don't set pbNewLine of the second (you only have one line in your row layout anyway).
Also, when you set pbFillHeight to true it makes no sense to also set the piHeight property on the same object.
Did that change anything?
-Sture
-
Re: Selection popup
I removed pbFillHeight, did not realize it was in there.
I want to have a detail line under the main description. I am augmenting the OnManualLoad to carry two values. Isn't that what pbNewLine is used for?
However, changing both as recommended did not change anything.
Ben
-
Re: Selection popup
>> I am augmenting the OnManualLoad to carry two values. Isn't that what pbNewLine is used for?
Yes it is. I hadn't realized that's what you wanted.
Then it must be the fact that you webset the size dynamically. I donøt know why that doesn't work.
How about, for a start, leaving out the dynamic size-setting and then have a button in the modal panel that webset's the size to something. Does that work?
That's what I'd try anyway.
-Sture
-
Re: Selection popup
Took that out and pbResizable too. No luck.
I have rebuild this from scratch but every time I add a second column to the cWebList it behaves like that.
-
Re: Selection popup
Take out all size settings only leave the list with a width and a height. Also take out the width setting on the columns. Each columns width is defined by the list anyway.
If that doesn't change anything I don't know what to do.
-Sture
-
Re: Selection popup
Got it.
I removed following line:
[CODE]
Procedure OnLoad
Forward Send OnLoad
Send GridRefresh
End_Procedure
[/CODE]
Now its working just fine.
-
Re: Selection popup