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)
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.

53 replies

    • Fred
    • 8 mths ago
    • Reported - view

    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);


    function onclick(event : any) do
        var selHorse := first(select Horses where HorseID = event.HorseID);

    Is there a way to access other field's data from the event. part or can do I only have access to the recordId?


      • Fred
      • 8 mths ago
      • Reported - view

       that makes a lot of sense. thanks, Jacques

    • Patrick_W
    • 6 mths ago
    • Reported - view

     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?

      • Ninox developper
      • Jacques_TUR
      • 6 mths ago
      • Reported - view

       I should be able to do this. You'll need to indicate in the return value of the onclick function that you don't want to select the line. For example, by returning a JSON of type { select : false }. I'll look into it soon. Thanks for your patience.

Content aside

  • 6 mths agoLast active
  • 53Replies
  • 1374Views
  • 15 Following