B4J Question [SOLVED] [ABMaterial] Datetimepicker not working

John Naylor

Active Member
Licensed User
Longtime User
OK I'm tired and probably doing something stupidly wrong here.

If I use this code on my homepage I get a working ABMDatetimepicker....


B4X:
Sub ConnectPage()


    ' ConnectNavigationBar2 is purposely built for public pages... It does not require a login to view
    ABMShared.ConnectNavigationBar2(page,  "Home", "Home", "Home",  Not(ws.Session.GetAttribute2("IsAuthorized", "") = ""))

    Dim ABMGenPurchaseOrdersdate As ABMDateTimePicker = ABMShared.BuildDatePicker (page,"dpicker",ABM.DATETIMEPICKER_TYPE_DATE,0,"PO Date","")
    page.Cell(2,2).AddComponent(ABMGenPurchaseOrdersdate)

but when I use this on a modalsheet it doesn't work....

B4X:
    '║ 10,1                                                                                                                              ║
    '╚═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝

    ABMGenPurchaseOrdersModal.Content.AddRows(1,True,"").AddCells12(1,"")
    ABMGenPurchaseOrdersModal.Content.AddRows(1,True,"").AddCellsOS(2,0,0,0,6,6,6,"")
    ABMGenPurchaseOrdersModal.Content.AddRows(2,True,"").AddCells12(1,"")
    ABMGenPurchaseOrdersModal.Content.AddRows(1,True,"").AddCellsOS(2,0,0,0,6,6,6,"").AddCellsOS(4,0,0,0,12,6,6,"")
    ABMGenPurchaseOrdersModal.Content.AddRows(1,True,"").AddCells12(1,"")
    ABMGenPurchaseOrdersModal.Content.AddRows(1,True,"").AddCellsOS(2,0,0,0,12,12,6,"")
    ABMGenPurchaseOrdersModal.Content.AddRows(1,True,"").AddCellsOS(4,0,0,0,6,3,3,"")
    ABMGenPurchaseOrdersModal.Content.AddRows(2,True,"").AddCells12(1,"")
    ABMGenPurchaseOrdersModal.Content.BuildGrid ' IMPORTANT!
#End Region

    Dim ABMGenPurchaseOrdersTitleMessage As ABMLabel
    ABMGenPurchaseOrdersTitleMessage.Initialize(page, "ABMGenPurchaseOrdersTitleMessage", "Enter all fields for this order - PO Number will be generated on save" , ABM.SIZE_PARAGRAPH, False, "")
    ABMGenPurchaseOrdersTitleMessage.IsBlockQuote = True
    ABMGenPurchaseOrdersModal.Content.CellR(0,1).AddComponent(ABMGenPurchaseOrdersTitleMessage)

    Dim Seperator As ABMDivider
    Seperator.Initialize(page,"Seperator","")
    ABMGenPurchaseOrdersModal.Content.Cell(1,1).AddComponent(Seperator)


    Dim ABMGenPurchaseOrdersdate As ABMDateTimePicker = ABMShared.BuildDatePicker (page,"dpicker",ABM.DATETIMEPICKER_TYPE_DATE,0,"PO Date","")
    ABMGenPurchaseOrdersModal.Content.Cell(2,1).AddComponent(ABMGenPurchaseOrdersdate)

On the former I get a picker as per usual, on the latter I get something that seems to want to work but the usual picker pop up doesn't appear.

Any ideas?
 

John Naylor

Active Member
Licensed User
Longtime User
Page.refresh?
Picker.refresh?

Page refresh I've tried but I'll try picker.refresh shortly.

I thought I must have used a date picker on a modal sheet at least a few times in other places but having looked through my code it appears not.
 
Upvote 0

John Naylor

Active Member
Licensed User
Longtime User
Still no luck having run page.refresh & picker.refresh

I'm going to run up a fresh template and see what happens with the picker on an all new modal sheet.
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
I'm going to run up a fresh template and see what happens with the picker on an all new modal sheet.
If you do, could you export and post it? It will be easier for me to debug.

I suspect it may have something to do with the z-index. If so, I think we can make a workaround with javascript.

Alwaysbusy
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
My code for modal sheet using datepicker... Works fine...
What is your code for:
ABMShared.BuildDatePicker
?

B4X:
Sub BuildDateBox() As ABMModalSheet
    Dim msgbox As ABMModalSheet
    msgbox.Initialize(page, "datebox",  False, False,"")
    msgbox.IsDismissible = False
    'msgbox.Size = ABM.MODALSHEET_SIZE_LARGE
    
    msgbox.Content.AddRowsM(2, True,0,0, "").AddCells12(1, "")
    msgbox.Content.AddRows(1 , True, "") .AddCellsOSMP(1,0,0,0,6, 6,6, 0, 0,0,0,  "").AddCellsOSMP(1,0,0,0,6,6,6,0,0,0,0,  "")
'    msgbox.Content.AddRowsM(1, True,20,0, "").AddCells12(1, "")
    
    msgbox.Content.BuildGrid
    
    ' add paragraph   
    'msgbox.Content.CellR(0,1).AddComponent(ABMShared.BuildParagraph(page,"par1"," Set Date Range") )
    msgbox.Content.CellR(0,1).AddComponent(ABMShared.BuildParagraphBQWithZDepth(page,"par1","  Set New Meeting Date and Name (or recall past meeting)") )
    
        
'    msgbox.Footer.AddRowsM ( 1,False,0,0, "").AddCellsOS(1,0,0,0,6,6,6,"").AddCellsOS(1,0 ,0,0,6,6,6, "")
'    msgbox.Footer.BuildGrid 'IMPORTANT once you loaded the complete grid AND before you start adding components
    
    Dim dt As String
    dt = DateTime.DateFormat
    
    DateTime.DateFormat = "MMMM dd, yyyy"
    
    Dim mtlist As ABMCombo
    mtlist.Initialize(page,"mtlist1","SELECT EXISTING DATE",150,"")
    msgbox.Content.CellR(1,1).AddComponent(mtlist)
    
    Dim startdate As ABMDateTimePicker
    startdate.Initialize(page, "startdate",ABM.DATETIMEPICKER_TYPE_DATE ,qsd,"MEETING DATE","")
    startdate.ClickThrough = True
'    startdate.SetDate(qsd)
    'startdate.Refresh
    msgbox.Content.CellR(1,1).AddComponent(startdate)
    
    Dim pub1 As ABMInput
    pub1.Initialize(page,"meetname",ABM.INPUT_TEXT,"Meeting Name",False,"")
    pub1.Text = DateTime.Date(qsd)
    msgbox.Content.CellR(0,2).AddComponent(pub1)
    DateTime.DateFormat = dt
    
    
    

'    Dim enddate As ABMDateTimePicker
'    enddate.Initialize(page, "enddate",ABM.DATETIMEPICKER_TYPE_DATE , qed," END DATE","")
'    enddate.SetDate(qed)
 '   msgbox.Content.CellR(0,2).AddComponent(enddate)

    
    ' create the buttons for the footer
    msgbox.Footer.AddRowsM(1,True,0,0, "").AddCellsOS(1,6,6,6,3,3,3,"").AddCellsOS(1,0,0,0,3,3,3, "")
    msgbox.Footer.BuildGrid 'IMPORTANT once you loaded the complete grid AND before you start adding components
    
    ' create the buttons for the footer
    Dim msgyes As ABMButton
    msgyes.InitializeFlat(page, "dateok", "", "", "OK", "transparent")
    msgbox.Footer.Cell(1,1).AddComponent(msgyes)
    
    Dim msgno As ABMButton
    msgno.InitializeFlat(page, "datecancel", "", "", "Cancel", "transparent")
    msgbox.Footer.Cell(1,2).AddComponent(msgno)
    
'    Dim msgok As ABMButton
'    msgok.InitializeFlat(page, "dateok", "mdi-navigation-check",  ABM.ICONALIGN_LEFT, "OK", "transparent")
'    msgbox.Footer.Cell(1,1).AddComponent(msgok)
    
    Return msgbox
End Sub
B4X:
 
Upvote 0

John Naylor

Active Member
Licensed User
Longtime User
What is your code for:
ABMShared.BuildDatePicker
?

Hey Harris - My BuildDatePicker code is


B4X:
Public Sub BuildDatePicker (page As ABMPage, id As String, dts As String, d As String, title As String, theme As String) As ABMDateTimePicker
    
    Dim dt As Long = DateTime.Now
    
    Dim dtp As ABMDateTimePicker
    
    If d="" Then d=dt
    
    dtp.Initialize(page, id, dts, d, title, theme)
    dtp.UseTheme(theme)
    
    dtp.CancelText = "Back"
    dtp.PickText = "OK"
    dtp.TodayText = "Today"
    dtp.Language = "en"
    dtp.ReturnDateFormat = "DD/MM/YYYY"
    dtp.ReturnTimeFormat = ""
    dtp.FirstDayOfWeek = 0
    
    Return dtp
    
End Sub

I tried to replicate my problem in the Template code (the one that shows each device size when you fire it up) and it appeared to work fine there.

I didn't have chance to work on it yesterday properly but once finance meetings are over I will do some comparison checks.
 
Last edited:
Upvote 0

John Naylor

Active Member
Licensed User
Longtime User
Can you check the browser console for errors? (Chrome - F12 - Console). It may give us a clue.

Thanks for your ongoing help!

b4j.PNG

The errors that I've cut out are just 404's where I don't have image files in place.
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
Just to try, add these two lines to the BuildPage() of your Page:
B4X:
page.NeedsMask = True
page.NeedsDateTimePicker = True

Normally, ABM should detect this automatically, but maybe your project has a certain structure I did not anticipated. If this works, at least we know it is there that I have to continue looking into.

Alwaysbusy
 
Upvote 0

John Naylor

Active Member
Licensed User
Longtime User
Just to try, add these two lines to the BuildPage() of your Page:
B4X:
page.NeedsMask = True
page.NeedsDateTimePicker = True

Normally, ABM should detect this automatically, but maybe your project has a certain structure I did not anticipated. If this works, at least we know it is there that I have to continue looking into.

Alwaysbusy

Perfect! That has fixed everything!

Interestingly on that one page I also had to add page.NeedsActionButton=True to get the action button to display.

Thanks guys this is literally the best forum there is.
 
Upvote 0
Top