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.

27replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • After using this function, I noticed a flaw. When a row is already selected and you click on a column different from "selected", nothing happens, the popup does not open because the row was already selected. 

    To change this, just :
    - that the onclick function systematically returns false,
    - add yourself the popupRecord function to open the form when you want.

    function onclick(event : any) do
        var selCustomer := first(select Customer where ID = event.targetID);
        if event.targetColumnCaption = "selected" then
            selCustomer.(checked := not checked)
    select Customer

    With these modifications, the behavior of the list is identical to a normal list if you click

    Enregistrement de l’écran 2022-06-26 à 22.25.49 

    • Jacques TUR 

Like3 Follow
  • 1 mth agoLast active
  • 27Replies
  • 234Views
  • 9 Following