0

<span onclick> , Is it possible in a Formula (html) with for from to do loop ?

Hi,

I have seen resent posts where span onclick is discussed. I wonder if it is possible to implement this in my  example. I intedent do upload this as a DB, but I'm over storage limit and cant download backups now 😅

In the example DB I have two Tables. 1: Persons, witch is just a list of names 

2:  Dashboard. I have two example FX fields here, see image below.

 In the yellow FX I have this code, that shows the Last name as a tooltip when i move the mouse in the list:

let pers := (select Persons);
let c := cnt(pers);
let p := 0;
for p from p to c do
    let x := slice(pers, p, p + 1);
    sort(html("<div class='cards-values' title =  """ + x.'Last name' + """>" +
        "<font color=DarkRed>" +
        x.'Last name' +
        ", " +
        "<font color=Black>" +
        x.'First name' +
        " " +
        x.Patronym +
        "<br>"))
end

 

In the green FX i want similar using span onclick,  with popupRecord or alternalivly openRecord when i click the mouse.

Current Green FX code, where I hope someone can edit the code and make this work 👍

let pers := (select Persons);
let c := cnt(pers);
let p := 0;
for p from p to c do
    let x := slice(pers, p, p + 1);
    sort(html("<div class='cards-values' title =  """ + x.'Last name' + """>" +
        "<font color=DarkRed>" +
        x.'Last name' +
        ", " +
        "<font color=Black>" +
        x.'First name' +
        " " +
        x.Patronym +
        "<br>"))
end

 

DASHBOARD

6 replies

null
    • Ninox partner
    • RoSoft_Steven.1
    • 1 yr ago
    • Reported - view
    • Haavard_Hjorteland
    • 1 yr ago
    • Reported - view

    Thank you, 

    Sorry, but I dont think I'm capable to adopt that to my exampe..

    My "green script" is like this, very basic. The above posted green script was a copy/paste mistake as it is a copy of the yellow script.

    Could you propose how this script would be to implemen "on click"? 

    let pers := (select Persons);
    let c := cnt(pers);
    let p := 0;
    for p from p to c do
        let x := slice(pers, p, p + 1);
        sort(html("<font color=DarkRed>" + x.'Last name' + "<font color=Black>" + ", " +
            x.'First name' +
            " " +
            x.Patronym +
            "<br>"))
    end

    • Ninox partner
    • RoSoft_Steven.1
    • 1 yr ago
    • Reported - view

    Here you are:

    let list := join(for i in select Persons do
            "<span onclick=""ui.popupRecord('" + raw(i.Id) +
            "')""; style=""color: DarkRed; cursor: pointer;"">" +
            i.'Last name' +
            "</span><font color=Black>" +
            ", " +
            i.'First name' +
            " " +
            i.Patronym +
            "<br>"
        end, "");
    html(list)

    I have used the "ui.popupRecord" here for convenience.

    You can also sort by adding sort by in the select function in line 1

    e.g.:

    for i in select Persons order by 'Last name' do ....

      • szormpas
      • 1 yr ago
      • Reported - view

        Hi, I just used your code in one of my Dashboard and I can confirm that it works seamlessly. It's something I've been looking for a long time. The ui.popupRecord function is very useful and I hope Ninox will continue to support it in the future. I appreciate your support!

    • Haavard_Hjorteland
    • 1 yr ago
    • Reported - view

    Wow, this was just brilliant 👍

    It  works well , but now I'll have to adapt/adjust and see how I can make it fit in my real scripts, witch usually are a bit more complicated.

    Thanks a lot 🙂

Content aside

  • Status Answered
  • 1 yr agoLast active
  • 6Replies
  • 441Views
  • 4 Following