0

Detect list selection

In a table view/list, select a row and the form slides out. One can move the selection up and down the list and the form data changes to reflect the selected row. Standard Ninox behaviour.

Is there any way to detect when a (different) row is selected? Basically a trigger when the row selection changes?

36replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
      • UKenGB
      • UKenGB
      • 2 wk ago
      • Reported - view

      Jacques TUR It most certainly will. Thanks for the extended function and for the pointer to where I can find it. I think it will be extremely useful. 馃憤

      Like
      • UKenGB
      • UKenGB
      • 2 wk ago
      • Reported - view

      Jacques TUR How does one add the onSelect function to the actual main list view of a  table? Not just a 'view' field added to a form where one creates the selection and can add the onSelect function, but the main list view of a table for which (as far as I am aware) there is no access to the selection code that creates the list and hence nowhere to insert the function code.

      Can your new function be used in that context?

      Like
    • UKenGB I think it's possible by inserting the onSelect function into the Visible If trigger of the table. I have to look if it's possible.

      What would be the use for you? What will this allow you to do?

      Like
      • UKenGB
      • UKenGB
      • 2 wk ago
      • Reported - view

      Jacques TUR  I need to run some code when a row is first selected or changed. I have a workaround that requires clicking a button instead, but would be so much better if this was done automatically when selecting the row in the table list.

      Like
    • UKenGB There is a simple way to do this, just add a tab first in the list of fields:

      Then you add your code in the Display If trigger

      Don't forget to put true (or any other formulas) at the end of your code for the tab to be displayed.

       

      Enjoy 馃槉

      Like
      • UKenGB
      • UKenGB
      • 2 wk ago
      • Reported - view

      Jacques TUR Ah, but my code needs to set a value and Ninox complains:-

      "This formula may not modify data"

      馃槚

      Like
      • UKenGB
      • UKenGB
      • 2 wk ago
      • Reported - view

      Jacques TUR I can use 'Trigger before view' which works the first time the record is opened, but that is not triggered just when switching rows.

      Like
    • UKenGB I created the function in a new version of Ninext/exViewEvent:

      It's still only a prototype and we'll have to test it to check that it works well in all cases.

      Just add an onselect function in the CanRead trigger (I also added a yes/no field named readed to test the function).

       Here is an example of code to add to the canRead trigger:

      function onselected(event : any) do
          var rec := first(select Customer where string(ID) = event.ID);
          if rec then rec.(readed := true) end
      end;
      true

      And here is the result: the readed field updates automatically each time the record is selected from the table (and only from the table).

       

      Like 1
    • Jacques I just saw that I complicated things a little for nothing. It is not useful to pass the record number as a parameter since it is that of the current record (this).

      The procedure code is therefore now easier to use:

      function onselected() do
          this.(readed := true)
      end;
      true

      The new version number is now 1.07 beta:

      Like
    • UKenGB
    • UKenGB
    • 2 wk ago
    • Reported - view

    I will get back to this shortly, but could I ask a couple of questions here (asked on Github, but it seems you are not reading those 'issues':-

    Does the code to load these have to be run for every session or only once and then it's downloaded and hence persistent between sessions?

    What is meant by 'file' and 'comment' in badges.html:? To what are you referring since Ninox is a database and as such, one is not working with either?

    In the Ninox editor, I already see a list of possible 'completions'. What does completion.html do that Ninox is not already doing? Are they mutually incompatible?

    Like
    • UKenGB Indeed, I had not received a notification for your message. It's surprising 馃. At the same time, I'm not very familiar with Github and I'm learning to use it as I go.I have returned an answer to all your questions on Github. I hope you have received an email to notify you.

      Thank you for all your questions馃槉

      Like
    • UKenGB Here is an example of initializing Ninext using the after open trigger.

    • UKenGB
    • UKenGB
    • 2 wk ago
    • Reported - view

    Ok, I can see what it's doing, but could that initialisation code be placed actually in 'Trigger after open'? Surely is just needs to run and doesn't matter where, just as long as it does run on opening the database?

    I tried:-

    var configLoadModules := {
            completion: false,
            badges: true,
            evalJS: true,
            viewEvent: true
        };
    html(http("GET", "https://raw.githubusercontent.com/JacquesTur/Ninext/main/loadModules.html").result);

    in the console as I can also see no reason for that to not work, but the displayed result was just the unformatted text of loadModules.html.

    Is there a reason why the above only works when run in some places, but not others?

    Like
    • UKenGB
    • UKenGB
    • 2 wk ago
    • Reported - view

    The above, placed in a formula field does load the extended functions, but not in either the Console, nor in 'Trigger after open' and I cannot really figure out why.

    Is there any way to make it run in 'Trigger after open' as that's the ideal place for it, designed specifically for code to run once, only when the database is first opened.

    Like
    • UKenGB if you run the init script in the console it will return the html but it won't run it.

      To install the code of Ninext, it is necessary to execute JavaScript.  The only way to do this with Ninox (without Ninext) is to go through an html field whose content only runs when it is displayed on a window (a form).

      The most unobtrusive solution I've found is to open an initialization window that displays the fields and closes right after the Ninext code is executed.  This form is usually not visible to users in the list of tables and is only opened when the application is started by the 'tigger after open'.  

      In the end, for the user it is very inconvenient and it can also be an opportunity to display a welcome message.

      Like
      • UKenGB
      • UKenGB
      • 2 wk ago
      • Reported - view

      Jacques TUR I thought it was probably as you say.

      I had an idea, but dialog() won't allow html and although alert() doesn't complain, it just displays the JS and doesn't run it. So that was a bust. 馃槚

      As you say, have to integrate a startup process with suitable display.

      Since this level of control of the user interface is so obviously possible (you've done it), why does Ninox not include this themselves so we can avoid this faffing about just to load extra stuff to get around what Ninox cannot do. The solution isn't rocket science. It's all there for them. Could not be simpler.

      Anyway, thanks Jacques. You are an inspiration.

      Like
    • UKenGB
    • UKenGB
    • 2 wk ago
    • Reported - view

    Now I am completely confused. I ran the code to load the modules in a formula field, saw the expected result and then clicking on any row in the table's main view, the onSelected function was working correctly.

    I then set up the Initialisation table with a formula field to load the modules and that provides the same correct result as expected. However when I then try the table row selection that was working (once modules loaded), it doesn't work.

    As a test I have another formula field doing the JavaScript calculation from your example and I can see the result is 30. So the modules are loaded, but onSelected is not working.

    I've put an 'alert' into the function, but it never shows. I moved it outside the function and it is displayed once when first going to that table, but not again when just selecting rows. So either it is not always showing alerts every time it runs that 'Readable if鈥' code, or that code is not often run. In either case the function doesn't seem to run.

    All of which has me confused since it was working before I set up the initialisation stuff.

    Any suggestions? Did you change the module code?

    Like
    • UKenGB
    • UKenGB
    • 2 wk ago
    • Reported - view

    I set up a very simple test, exactly as you did in the example above. In 'Readable if' I have:-

    function onselected() do
        this.(testbool := true)
    end;
    true
    

    testbool is as it seems, a simple boolean (yes/no) for testing. I can click on any row in the table and that field is not updated (from default null).

    As far as I can determine, that onselected() function is simply not running. But it did yesterday.

    ????

    Like
    • UKenGB The EvalJS app work or not ?

      Could you send me one application to test it ?

      Like
      • UKenGB
      • UKenGB
      • 2 wk ago
      • Reported - view

      Jacques TUR On same form as field testbool, there is the JavaScript calculation (from your test example) that always shows 30, so that is working.

      Like
    • UKenGB
    • UKenGB
    • 2 wk ago
    • Reported - view

    The only difference I can think of is that yesterday I ran the load module code in a formula field on that same form (next to the test JS calculation), whereas now it is being run in the initialisation table. But either way, the JS calculation runs correctly.

    Like
    • UKenGB
    • UKenGB
    • 2 wk ago
    • Reported - view

    That's it. The modules have to be loaded by a formula field in that table, or the onselected() function doesn't run, even though the JS calc still works.

    When the modules are loaded by that initialisation routine all using a different table, onselected() doesn't run when used in other tables.

    Your example shows it all working in that same table, so the problem did not arise.

    Like
    • UKenGB I can't seem to reproduce the problem. In the attached example, I put an onselected in all tables and it seems to work fine.

      Can you send me an example that does not work?

Like Follow
  • 8 hrs agoLast active
  • 36Replies
  • 139Views
  • 2 Following