Setting foundset property in serverside scripting

Forum to discuss the new web client version of Servoy.

Setting foundset property in serverside scripting

Postby robrecht » Sun Jun 11, 2017 7:59 pm

Hi,

I want to set the foundset property of a custom component at runtime like described in the documentation.
However I get an error when I want set this property.

Code: Select all
var _grid = forms.Demo_ArticleGrid_InMemory.elements.Data_Grid_1
   _grid.foundset = 'mem:article_inmem'


Gives this error in developer :

> java.lang.RuntimeException: Cannot set mem:article_inmem into a foundset property type; for existing foundset properties you can set the myProp.foundset or myProp.dataproviders directly. If you want to set a complete new value you have to give here something like { foundset : ...someFoundset..., dataproviders : { dp1: 'userNickname', dp2: 'userReviewRating', ... } } instead.
at com.servoy.j2db.server.ngclient.property.FoundsetPropertyType.toSabloComponentValue(FoundsetPropertyType.java:361)


I also tried with the suggested { foundset : ...someFoundset..., dataproviders : { dp1: 'userNickname', dp2: 'userReviewRating', ... } } , but that resulted in the same error.



Robrecht
robrecht
 
Posts: 99
Joined: Wed Aug 01, 2012 4:30 pm

Re: Setting foundset property in serverside scripting

Postby robrecht » Sun Jun 11, 2017 8:06 pm

Solved,

I had to use the actual foundset reference instead of the foundset name.

Code: Select all
var _res = _ds.createDataSource('article_inmem')
var _fs = databaseManager.getFoundSet(_res)
_fs.loadAllRecords()
   
var _grid = forms.Demo_ArticleGrid_InMemory.elements.Data_Grid_1

var _foundset = {
      foundset:_fs,
      dataproviders:{
         dp0:'article_code',
         dp1:'article_group',
         dp2:'description'
         }
   }
   
_grid.foundset = _foundset
robrecht
 
Posts: 99
Joined: Wed Aug 01, 2012 4:30 pm


Return to Servoy NGClient

Who is online

Users browsing this forum: No registered users and 22 guests

cron