0

Views

It always creates confusion when the same word is used to describe different things. Ninox can create tabs at the top of the main window and these are called 'Views'. Then there is a layout type field called a 'View'. Brilliant.

While I appreciate they have similarities, they are factually different and trying to discuss either requires clarification of precisely which is being discussed - clarity so often missing in discussions on this forum and even in Ninox documentation where they state Views (apparently referring to big top tab Views) can show filtered data and if anyone knows how to actually filter the data shown in a big top tab View, please let me know as having to mess with a column's values and filters is quirky at best and inconsistent. Those Views need a simple way to filter the rows shown, not necessarily based on visible columns. Anyway…

I actually have a question about View fields.

Having created a small table of records to show on a form, I want to programatically count the number of rows displayed, to use that number elsewhere. However, it appears to be impossible to access a View field in any script anywhere as the View field is not listed for easy selection and typing the actual field name just produces en error that the field cannot be found.

Is there actually a clever way to make programmatic use of such a View field? In particular I need to know if it contains any rows but currently am completely stumped. Or are we denied any such access?

14 replies

null
    • UKenGB
    • 5 days ago
    • Reported - view

    Actually just figured out how to count the rows:-

    Create a formula field that gathers the records. You can count() this.

    Then create a view and make it equal to the formula field above.

    Works but seems bit cludgy. Why can't I simply count() a View field?

    • Fred
    • 5 days ago
    • Reported - view

    I would throw out the idea that a view element does its one job very well, which is to show you the array of records that was discovered in the formula. So it is not just an array that you can count.

    You can try: 1) creating a formula field, we will call it rawData, with the exact same formula as the view element. 2) Then in the view element formula put in rawData. 3) Now you can create another formula field that counts rawData. This way you only need to make 1 change and it will propagate to all your other formulas.

      • UKenGB
      • 3 days ago
      • Reported - view

       Thanks. So what I said then. 😄

      • Fred
      • 3 days ago
      • Reported - view

       oops, yes you are correct. brain fart on my end. 😗

      • UKenGB
      • 3 days ago
      • Reported - view

       😂

    • UKenGB
    • 3 days ago
    • Reported - view

    Another problem I find. To be clear again, I am referring to the 'View' field/element and not a top tab view.

    When I programatically change something that is displayed in the View, only some of the rows show the change. Which rows update seems random, but importantly, the data being displayed is no longer correct.

    Simply pressing the 'Refresh/Redraw' button top left of the main table immediately corrects this and everything is then displayed accurately. How can I do this programatically?

    The only solution I can come up with is to include at the end of the script:-

        closeRecord();
        popupRecord(c)
    

    This works (c being previously set to 'this'), but causes a visual glitch as the popup closes and opens again, whereas it just needs to redraw. Obviously possible as there is the built-in button to do this, but we have no access to that.

    Anyone suggest how best to  force redraw in a script?

      • John_Halls
      • 3 days ago
      • Reported - view

       Does the data that's displayed but not being updated come from a formula field, and does this formula field use a select statement?

      • UKenGB
      • 3 days ago
      • Reported - view

       It's the same problem that always seems to occur with the main table view. Ninox randomly blanks some cells when any changes are made. I say 'cells' but it could be entire rows, or maybe a column. This is the Mac app and it's been reported before.

      This particular problem just seems to be an extension of that and since the updates are being done by a script, it would be convenient if there was a simple 'redraw()' command.

      As an example, I have a formula field that gathers records from another table and then that is shown in a View element (made equal to the formula field). I then run the script that changes data on which the original selection is performed, ideally at the end of the script all rows would have gone and leave an empty View. However some/all of the rows are still displayed until I redraw (or close the popup and open it again as I showed above).

      Another example involves including a boolean field created as 'per record in memory'. Added to the View as a column gives me a nice checkbox on each row which I can use to choose which rows to process in a script. All works fine, but I also added a button to select All or None of the rows and these also work, but the appropriate change is only shown in one (or maybe 2, I forget now) rows only. Click redraw (or close and open as I said) shows that in reality, the script has done exactly what it was supposed to, but Ninox didn't bother to redraw the View. It's just a display problem.

      Using checkboxes like this to select individual rows of a View is exactly what I want to be able to do and it all works perfectly, so not really wanting to look for some other solution as my redraw commands above do work. It's just a messy way to have to get around the fact that Ninox is not doing what it should.

      So I was just wondering if there is any better way to effect this redraw, just as if manually clicking the Redraw button top left of the main screen.

    • John_Halls
    • 3 days ago
    • Reported - view
     said:
    I have a formula field that gathers records from another table

     Could you post a copy of the code that is in this formula field.

    Thanks John

      • UKenGB
      • yesterday
      • Reported - view

       For what it's worth:-

      let theCurrentLighting := 'Lighting🔗ⁿ'.'Lighting🔗¹';
      let thisModV := 'Model∆🔗¹';
      (select 'bulb∆s⛓lighting⛓model∆s')['Model∆s🔗¹' = thisModV and not contains(theCurrentLighting, 'Lighting🔗¹')]
      

      It is however my position that no matter what data nor how the records are collected (and since they do initially display correctly), any change to any data that is displayed, the display should update to reflect that change. The fact that data shown is not updated in the display is as far as I'm concerned a fault of the code that comprises this app, i.e. Ninox.

      To get around this problem, I just want the best way to perform a redraw.

    • John_Halls
    • yesterday
    • Reported - view

    Hi 

    It's worth a lot!

    If this is in a formula field, which you say it is, then the problem lies with using a select command to gather the data. Select commands need a reason to run, which works in a button or trigger but in a formula field they don't always run (it would be detrimental if they did). I think it would need a change in the values of

    Lightingⁿ'.'Lighting¹'

    or

    'Model∆¹'

    to trigger it, but I'm not sure.

    See if you can collect the data in another way, through a relationship maybe?

    Regards John

      • UKenGB
      • yesterday
      • Reported - view

       I didn't think I could achieve it through relationship fields, but I didn't try very hard. I'm thinking now that it may be possible so I'll have a good look at that as I need to make some changes anyway.

      Thanks for the suggestion.

      • John_Halls
      • yesterday
      • Reported - view

       That's OK. One thing that might be worth doing is to change

      (select 'bulb∆slightingmodel∆s')['Model∆s¹' = thisModV and not contains(theCurrentLighting, 'Lighting¹')]
      

      to

      (select 'bulb∆slightingmodel∆s'where'Model∆s¹' = thisModV and not contains(theCurrentLighting, 'Lighting¹'))
      

      The difference is that the first, with [], pulls down all the records and then scopes these by the boolean test inside the square brackets. The second, with the where clause, only pulls down the matching records.

      Might help

      John

      • UKenGB
      • yesterday
      • Reported - view

       Thanks, very interesting. I was under the impression they are simply different ways to express exactly the same filter. I didn't realise they operated differently. Not sure why as a former SQL scripter I  switched to more usually using [ ] in Ninox. Less typing perhaps. 🙂

      I will certainly return to using WHERE instead. Good tip.

Content aside

  • yesterdayLast active
  • 14Replies
  • 68Views
  • 3 Following