ltg if

35 views
Skip to first unread message

Edu Reyes Jr

unread,
Sep 27, 2021, 6:48:20 AM9/27/21
to Lightning - 4D Web Applications
I understand that in Lightning 4 there's an LTG IF, and it seems like it doesn't exist anymore in Lightning 5. What is the replacement to this or an is there an alternative?

What we want to do is to call a dialog box only when a specific option is selected. And currently we are controlling this call via the html code.

Is there anyone who's working/worked on something like this? How are you handling this condition?

TIA

- Edu Reyes

Graham Langley

unread,
Sep 27, 2021, 7:16:47 AM9/27/21
to Lightning - 4D Web Applications
The ltg-if doesn't exist in V5 as there are no ltg-x tags anymore. The alternative would be <!--4DIF--> but you will run into variable scope issues due to Lightning being a component. 

Personally I do not have any need for the conditional pre-processing tags, instead I find another way of injecting, or showing/hiding elements using Javascript and CSS classes, eg "d-none" in Boostrap 4 will not display the element and then removing the class "d-none" will  display the element, simple and effective.

What we want to do is to call a dialog box only when a specific option is selected. And currently we are controlling this call via the html code.

Take a look at the Starter demo, goto Companies detail form and click delete, that will launch a dialog using ltgDialogOpen('<dialog-id>'), 4D project method is Company_Delete, but you could do the opening of the dialog browser side via a custom JS method or onclick events also.

Edu Reyes Jr

unread,
Sep 28, 2021, 2:57:09 AM9/28/21
to Lightning - 4D Web Applications
is the a way to call a separate html file for the dialog? just like the way an edit form is called.

in the  Company_Delete example,  ltgDialogOpen('<dialog-id>') runs a section of the html file to open a confirm dialog.
using this example, if I want to do an edit dialog, i will have to put all the fields in that section. that seems to work but I already have an html edit dialog, can I call this instead?
I tried to put "include" in that html section but that didnt' work. I also tried  ltgDialogOpen(<html filename>), that didnt' work either.

Thanks.

Graham Langley

unread,
Sep 28, 2021, 4:09:42 AM9/28/21
to Lightning - 4D Web Applications

Take a look at the Contacts detail form (contacts-detail.html) in the demo, this is a modal form in a separate html file.

The important part is to include "modal=true" in the ltgFormAction function call as below (taken from contacts-list.html);

<a href="#" onclick="ltgFormAction(\'contacts-detail.html?action=edit&modal=true&record='+row[1]+'\');"

Edu Reyes Jr

unread,
Sep 28, 2021, 4:20:48 AM9/28/21
to Lightning - 4D Web Applications
Yes, I understand this part. but anyway, here's the context.

I have a pulldown. I add an element that says: "Add record..."
What I want to do is:
if I select the "Add record..." option, edit dialog, else do nothing.

Graham Langley

unread,
Sep 28, 2021, 4:28:48 AM9/28/21
to Lightning - 4D Web Applications
Refer to contacts-list.html;

            <div class="dropdown-menu">
                <a class="dropdown-item" onclick="ltgFormAction('contacts-detail.html?action=new&modal=true');" href="#">{{%new}} {{%contact}}</a>
                <a class="dropdown-item" onclick="ltgFormAction('?action=delete-confirm&method=Contact_Delete');" href="#">{{%delete}} {{%contacts}}</a>
            </div>



Edu Reyes Jr

unread,
Sep 28, 2021, 4:47:26 AM9/28/21
to lightning-...@googlegroups.com
Yes, basically this is what I actually followed. 

This code is when we want a new record. That's fine. 

onclick="ltgFormAction('contacts-detail.html?action=new&modal=true') will always call contacts-detail.html no matter what option you choose. and this will always call "Contact_Detail" method so control goes back to 4D.

So when I click my "Add record..." it's good. But when I call the other options, this will also fire. So I'm figuring out a way to skip the dialog when other options are selected. Actually I found a way (in 4D side) but it's a work around. Hence, I asked about "ltg if"

I was also able to make the Confirm dialog work. So now it works like, confirm dialog -> "Do you want to add?" Yes -> then calls the html edit dialog.




--
You received this message because you are subscribed to a topic in the Google Groups "Lightning - 4D Web Applications" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lightning-4d-web-apps/EL9r5MjWR4U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lightning-4d-web...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lightning-4d-web-apps/bd182afb-65df-4f41-888f-c72c78cc7178n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages