B4J Question [ABMaterial] AddSubItem in ABMList does not work with ABMEditor

MichalK73

Well-Known Member
Licensed User
Longtime User
Hello.
I encountered a problem. I have the html content that I want to display in the AddSubItem as ABMEditor. I do not have any errors, but it does not show me, it does not even develop after clicking on the list item. As I will give it in the AddSubItem ABMLabel it works perfectly but you can see html markups and want the formatted html text from ABMEditor to display.
What am I doing wrong and maybe there is some other way around this problem.

B4X:
public Sub ConnectPage()
....
....
....
   Dim list As ABMList
    list.Initialize(page, "list", ABM.COLLAPSE_EXPANDABLE, "")
    Dim wynik As List
    wynik = DBMh.SQLSelect("select * from faq")
    For i =0 To wynik.Size-1
        Dim m As Map = wynik.Get(i)
        list.AddItem(m.Get("idx"),tytul(m.Get("title")))
        list.AddSubItem(m.Get("idx"),"a"&m.Get("idx"),odpowiedz(m.Get("value")))
    Next
    
    page.Cell(3,1).AddComponent(list)
    
    page.Refresh
    page.FinishedLoading
End Sub

Sub tytul(value As String) As ABMLabel
    Dim a As ABMLabel
    a.Initialize(page,"1",value, ABM.SIZE_H5,True,"")
    a.Clickable = True
    Return a
End Sub

Sub odpowiedz(value As String) As ABMEditor
    Dim ed As ABMEditor
    ed.Initialize(page,"1",False,False,"")
    ed.SetHTML(value)
    Return ed
End Sub
 

alwaysbusy

Expert
Licensed User
Longtime User
ABMEditor does not work well together with ABMList. This is because each ABMEditor is kind of a complete webpage itself (it is an iFrame with its own, css, js, etc files). So if for example you have a list with 20 items, then you are actually loading 20 (+1 for the page itself) full webpages.

So the first question you have to ask: does the input field really need an ABMEditor?
Do you need, in this field, that the user enters formatting? (be aware that an ABMEditor can even contain pictures, bullet lists etc, and there is no way they will ever be able to be presented outside an ABMEditor)

But this is the second time this question comes up, so I will need to find some kind of solution for this.

Maybe something like .GetABMText/.SetABMText which would 'try' to convert between the HTML to ABM formatting tags ({B}, {I} etc). This would of course be somewhat limited (losing pictures for example). Maybe even in that case use a limited toolbar:

upload_2018-5-9_14-6-46.png


I you come up with some other ideas, post them here.
 
Upvote 0

MichalK73

Well-Known Member
Licensed User
Longtime User
In the webapp panel I have ABMEditor used to build a FAQ for the client. It has basic elements like bullets, inserting an image. The result is saved to the database and the FAQ information from the database will be displayed on the user's page (another ABMaterial webapp). That's why I wanted to use ABMEditor to preview hints from the HTML format written in ABMEditor with the editing and the bar off.
An even better solution for me would be that the server from the base would generate separate HTML files for themes. However, I do not know how to insert full separate HTML code into a component in ABMaterial. ABMLabel has limited HTML tags and I would prefer more.
It could come in handy for some new method or small component that would display any HTML content.
 
Upvote 0

MichalK73

Well-Known Member
Licensed User
Longtime User
OK.
I added the method to click ABMList. It works displaying from the base and it can even be for now.

B4X:
Sub list_Clicked(ItemId As String)
    Dim t As String = DBMh.SQLSelectSingleResult2("select title from faq where idx=?", Array As String(ItemId))
    Dim v As String = DBMh.SQLSelectSingleResult2("select value from faq where idx=?", Array As String(ItemId))
    Dim okno As ABMModalSheet = page.ModalSheet("AddModal")
    Dim tyt As ABMLabel = okno.Content.Component("tyt")
    Dim tresc As ABMEditor = okno.Content.Component("edit")
    tyt.Text = t
    tresc.SetHTML(v)
    tyt.Refresh
    tresc.Refresh
    page.ShowModalSheet("AddModal")
End Sub
 
Upvote 0
Top