Child pages
  • Foundset property type
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

Spec file:

A component can have in the spec file just something like:

"myfoundset": "foundset"

 

Then we have to have also a components property that maps on this one:

"childElements" : { "type" : "component[]", "elementConfig" : {"forFoundsetTypedProperty": "myfoundset"} }, `

 

 Then the components dictate which dataproviders will be send over for that foundset selector.

Or we can have by configuration type, so instead of childelements we have:

 

"myconfigurations": "MyConfig"
"types": {
    "MyConfig": { 
        "mydataprovider" : { "type" : "dataprovider", "forFoundsetTypedProperty": "myfoundset"}
    }
}

Then the configuration dictates which dataproviders are send over  for that foundset.

In these 2 scenario's the viewport of the foundset only contains the rowid's and the components (childElements) or configuration (myconfigurations) have the viewPort for that row data (we as an example below)

 

Besides these 2 options where which dataproviders are defined by another property the foundset property can also define the dataprovider itself:

"myfoundset": {"type":"foundset", "dataproviders":["firstname","lastname"]}

 

Now the foundset itself just specifies what dataproviders it expects in its viewport rows.

The dataproviders will be mapped just like a normal webcomponent, so in the browser value you will have "firstname" and "lastname" and those are filled in on the server side based on the dataprovider they are mapped on in the designer.

Browser value:

Here is a sample of what the value of a 'foundset' typed property contains in the browser - web component model:

Browser side provided property content in model
myFoundset: {
    serverSize: 44, // the size of the foundset on server (so not necessarily the total record count in case of large foundsets)

    // this is the data you need to have loaded on client (just request what you need via provided loadRecordsAsync or loadExtraRecordsAsync)
    viewPort: {
        startIndex: 15,
        size: 5,
        rows: [ { _svyRowId: 'someRowIdHASH1', nameColumn: "Bubu" },
                { _svyRowId: 'someRowIdHASH2', nameColumn: "Yogy" },
                { _svyRowId: 'someRowIdHASH3', nameColumn: "Ranger" },
                { _svyRowId: 'someRowIdHASH4', nameColumn: "Watcher" },
                { _svyRowId: 'someRowIdHASH5', nameColumn: "Hatcher" } ],

        /** Request a change of viewport bounds from the server; the requested data will be loaded asynchronously in 'viewPort'
          * @param startIndex the index that you request the first record in "viewPort.rows" to have in the real foundset (so the beginning of the viewPort).
          * @param size the number of records to load in viewPort.
          */
        loadRecordsAsync: function(startIndex, size),

        /** Request more records for your viewPort; if the argument is positive more records will be loaded at the end of the 'viewPort', when negative more records will be loaded at the beginning of the 'viewPort' - asynchronously.
          * @param negativeOrPositiveCount the number of records to extend the viewPort.rows with before or after the current loaded records.
          */
        loadExtraRecordsAsync: function(negativeOrPositiveCount)
    },

    selectedRowIndexes: [16], // can be out of viewPort as well
    multiSelect: false
}

Initially the viewPort is an empty array (size 0) and startIndex is 0 as well. Client side JS can watch the value of serverSize and when recods become available it can request the desired Viewport using loadRecordsAsync.

If more records need to be shown besides the already loaded ones use loadExtraRecordsAsync.

Changes made in browser to viewPort.rows data content (so column value modifications) will be sent server-side.

Changes made in browser to selectedRowIndexes content will change selection on server side as well.

Design value (generated visually by form designer and written in .frm file, so Servoy users don't need to know about it)

Contents in .frm file
myFoundset: {
        foundsetSelector: "", 
        dataproviders: [firstname:'columnOrOtherDataprovider',lastname:"someotherDataprovider"]
    }
}"

'foundsetSelector' can be:

  • "" - use parent (form's) foundset;
  • "myRelation" will give a related foundset;
  • "datasource" would give a seoarate foundset for the given datasource

'dataProviders' specifies what are the data columns mappings that need to be available in the browser - in the foundset property's 'viewPort' - in rows. These are only there if the foundset property in the spec are asking for specific dataproviders.

Runtime usage (server side Servoy JS)

[TODO] just make the ususal foundset obj. available in scripting

  • No labels