Child pages
  • Foundset property type

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Purpose of this property type

Info

This page is intended written for NG web component creators, not for Servoy developers that just want to use web components.

...

  • a (parent) form's foundset
  • a related foundset
  • a separate foundset (of any table; smilar similar to JSDatabaseManager.getFoundset()). When this option is chosen the user can also choose whether or not the separate foundset should load all records initially. (if not checked, contents can be loaded at any time from scripting)
  • "- none -" which means that you are going to set that foundset at runtime through scripting.

...

This was added in order to improve performance by removing the need for angular watches. You no longer need to add lots of angular watches, deep or collection watches in order to be aware of incomming server changes to the foundset property. Each such watch would slow down the page - as watches are triggered a lot for all kinds of user actions or socket traffic. Also the listener can give more detailed information in order to do more granular updates to the UI easier.

So to add a incomming incoming server change listener to this property type just call:

...

Code Block
languagejs
titlewhat "changes" parameter can contain:
{
    // if value was non-null and had a listener attached before, and a full value update was
    // received from server, this key is set; if newValue is non-null, it will automatically get the old
    // value's listeners registered to itself
    foundsetTypeConstants.NOTIFY_FULL_VALUE_CHANGED: { oldValue : ..., newValue : ... },

    // the following keys appear if the each of these got updated from server; the names of those
    // constants suggest what it was that changed; oldValue and newValue are the values for what changed
    // (e.g. new server size and old server size) so not the whole foundset property new/old value
    foundsetTypeConstants.NOTIFY_SERVER_SIZE_CHANGED: { oldValue : ..., newValue : ... },
    foundsetTypeConstants.NOTIFY_HAS_MORE_ROWS_CHANGED:  { oldValue : ..., newValue : ... },
    foundsetTypeConstants.NOTIFY_MULTI_SELECT_CHANGED:  { oldValue : ..., newValue : ... },
    foundsetTypeConstants.NOTIFY_COLUMN_FORMATS_CHANGED:  { oldValue : ..., newValue : ... },
    foundsetTypeConstants.NOTIFY_SORT_COLUMNS_CHANGED:  { oldValue : ..., newValue : ... },
    foundsetTypeConstants.NOTIFY_SELECTED_ROW_INDEXES_CHANGED:  { oldValue : ..., newValue : ... },
    foundsetTypeConstants.NOTIFY_VIEW_PORT_START_INDEX_CHANGED:  { oldValue : ..., newValue : ... },
    foundsetTypeConstants.NOTIFY_VIEW_PORT_SIZE_CHANGED:  { oldValue : ..., newValue : ... },
    foundsetTypeConstants.NOTIFY_VIEW_PORT_ROWS_COMPLETELY_CHANGED:  { oldValue : ..., newValue : ... },

    // if we received add/remove/change operations on a set of rows from the viewport, this key
    // will be set; as seen below, it contains "updates" which is an array that holds a sequence of
    // granular update operations to the viewport; the array will hold one or more granular add or remove
    // or update operations;
    // all the "startIndex" and "endIndex" values below are relative to the viewport, 0 based
    foundsetTypeConstants.NOTIFY_VIEW_PORT_ROW_UPDATES_RECEIVED: {
        updates : [
            {
                    type : foundsetTypeConstants.ROWS_CHANGED,
                    startIndex : ...,
                    endIndex : ...
            },
            {
                    // when an INSERT happened but viewport size remained the same, it is
                    // possible that some of the rows that were previously at the end of the viewport
                    // slided out of it; "removedFromVPEnd" gives the number of such rows that were removed
                    // from the end of the viewport due to the insert operation;
                    // NOTE: insert signifies an insert into the client viewport, not necessarily
                    // an insert in the foundset itself; for example calling "loadExtraRecordsAsync"
                    // can result in an insert notification + bigger viewport size notification,
                    // with removedFromVPEnd = 0
                    type : foundsetTypeConstants.ROWS_INSERTED,
                    startIndex : ...,
                    endIndex : ...,
                    removedFromVPEnd : ...
            },
            {
                    // when a DELETE happened inside the viewport but there were more rows available in the
                    // foundset after current viewport, it is possible that some of those rows
                    // slided into the viewport; "appendedToVPEnd " gives the number of such rows
                    // that were appended to the end of the viewport due to the DELETE operation
                    // NOTE: delete signifies a delete from the client viewport, not necessarily
                    // a delete in the foundset itself; for example calling "loadLessRecordsAsync" can
                    // result in a delete notification + smaller viewport size notification,
                    // with appendedToVPEnd = 0                                 
                    type : foundsetTypeConstants.ROWS_DELETED,
                    startIndex : ...,
                    endIndex : ...,
                    appendedToVPEnd : ...
            }
        ]
    }

}

...

Info
titleFoundset change listener & other foundset linked properties (starting with 8.2)

In case you want to use a foundset property type change listener (for incomming changes from server) combined with other foundset linked properties such as dataproviders with "forFoundset", a change of a row on server will send changes both to the foundset property and to the dataprovider properties linked to that foundset. In order to make sure that your foundset notification update code executes after all property changes have been applied (so the dataprovider properties are also up-to-date) you can use:

Code Block
var l = function(changes) {
    // wait for all incommingincoming changes to be applied to properties first
    $webSocket.addIncommingMessageHandlingDoneTaskaddIncomingMessageHandlingDoneTask(function() {
        // now check to see what actually changed and update what is needed in browser
        // because even other "forFoundset" properties are up-to-date
    }
};
$scope.model.myFoundset.addChangeListener(l);

...