add onselect event for view field
In response to Alain Fontaine & Fred Christmas wish (https://forum.ninox.com/t/h7hbkmp?r=h7hbvzj), I have added a viewEvent function to Ninext project.
Just put viewEvent at true in an init code formula:
var configLoadModules := {
completion: true,
badges: true,
evalJS: true,
viewEvent: true
};
html(http("GET", "https://raw.githubusercontent.com/JacquesTur/Ninext/main/loadModules.html").result);
This will be returned:
All that remains is to add the onselect() event function to the view field source formula:
The full code of the view field is :
function onselect(selectedID : text) do
'Selected customer' := first(select Customer where ID = selectedID)
end;
select Customer
When you select a line in the field of view, the onselect function is called instead of the automatic event that displays a popup.
selectID represents the full (alphanumeric) id of the selected record. The context record this remains the owner record of the view field.
The second part (select Customer) is the standard initialization for the field of view content.
61 replies
-
Hi all -
Here is my setup. I have a dashboard, "All Horses Stats" that has a view element to a table called DashTemp. In DashTemp is a number field called HorseID.
Now I want to click on a record in the view element but onclick to a table called Horses but use the data in HorseID in DashTemp to match a similar field in Horses. I can't use recordId as there is no relationship between the tables.
I've tried:
function onclick(event : any) do var selHorse := first(select Horses where HorseID = event.targetId.HorseID); popupRecord(selHorse); true end;
and
function onclick(event : any) do var selHorse := first(select Horses where HorseID = event.HorseID); popupRecord(selHorse); true end;
Is there a way to access other field's data from the event. part or can do I only have access to the recordId?
Thanks,
-
Hi Jacques,
is it possible to deselect the selected line via script? When I click on a row, the row actually looks "selected". In my case, if I just want to trigger a true/false field like a checklist, I don't want to see a selected row.
Maybe it's possible to show the overlay as a mouseover instead?
-
This function doesn`t work since 3.12 anymore. I guess, it is in relation to Ninox bugfix of the blind view elements. Any hotfix possible?
-
I found out, that using this function causes a delay of 2 - 3 seconds, until the selected record appears in the popup. Do you it is possible to improve the popup speed like Ninext isn't used? Best regards, Ralf
-
Hello, my code in a view is
function onclick(event : any) do let a := first(select Aufgaben where Nr = event.targetID); if event.targetColumnCaption = "Done" then a.(Check := not Check); true else void end end;
But nothing happens. I checked several times if column name is "Done" and - of course - the view shows data with select Aufgaben. In the table "Aufgaben" exists a yes/no field with name Check.
I copied the code from another view where it works. I really have noch clue what makes the difference. When I click in the column "Done" the popup record opens instead to change the Check-field.
Maurice
Content aside
-
4
Likes
- 2 wk agoLast active
- 61Replies
- 1630Views
-
16
Following