Page 1 of 1

Valuelists based on data

PostPosted: Mon Feb 18, 2013 11:17 am
by vincentc
Hello,

I have a question concerning valuelists in Servoy Mobile.

I understand that "only custom valuelists are supported" in the Mobile side.

But in our case, we need absolutely to provide these valuelists by data from db.

Is there a way to make it from the Service side ?

For example : I have a table "Opportunity_status" which contains the possible values of my valuelist "Status". I would like to retrieve the data of this table and push in an array (or in an object), to be able to retrieve my data in the Mobile side.

Thank you very much.

Re: Valuelists based on data

PostPosted: Mon May 06, 2013 5:22 pm
by sanneke
Yes this is possible.
You can add a extra foundset to the retval and use this to fill your valuelist.

So you add for example this to the ws_read:
Code: Select all
var fs_codes = databaseManager.getFoundSet('db:/mobile/codes')   
   fs_codes.loadAllRecords()
   retval.addFoundSet(fs_codes, [])

Re: Valuelists based on data

PostPosted: Tue May 07, 2013 11:20 am
by vincentc
Thank you very much for your answer ! I will try this soon and I will let you know

Re: Valuelists based on data

PostPosted: Wed May 29, 2013 10:12 am
by vincentc
I successfully get offline valuelist data adding foundset to offline_data ws_read method

I couldn't find sample code to manage mobile valuelist

Could you please provide me sample

thanks

Re: Valuelists based on data

PostPosted: Thu May 30, 2013 2:31 pm
by sanneke
Here a sample:

Code: Select all
   var ids = []
   var values = []
   //set valuelists
   /** @type {JSFoundSet<db:/source/table>} */
   var fs = databaseManager.getFoundSet('db:/source/table')
   //remove this line if it gives a warning, in older version of servoy it is not needed in the last it is.
       fs.loadAllRecords()
   
   for (var i = 1; i <= fs.getSize(); i++) {
      var rec = fs.getRecord(i)
       ids.push(rec.id)
       values.push(rec.description)
   }
   
   appl

Re: Valuelists based on data

PostPosted: Tue Jun 04, 2013 2:32 pm
by vincentc
Thank you !

Re: Valuelists based on data

PostPosted: Thu Jan 02, 2014 7:14 pm
by andres.achiary
Hi, i revive this topic because i'm having trouble with a valuelist.

In the service solution I do:

Code: Select all
var clientes_vl = databaseManager.getFoundSet('db:/contador_hs/clientes')
   retval.addFoundSet(clientes_vl, []);


retval has other foundset that works fine

and in the solutionOpen of the mobile solution i do:

Code: Select all
   var ids = []
   var values = []
   
   /** @type {JSFoundSet<db:/contador_hs/clientes>} */
   var fs = databaseManager.getFoundSet('db:/contador_hs/clientes')
   fs.loadAllRecords()
   
   for (var i = 1; i <= fs.getSize(); i++) {
      var rec = fs.getRecord(i)
      ids.push(rec.cliente_id)
      values.push(rec.razon_social)
   }
   application.setValueListItems('clientes',values,ids)


am i missing something? When running the solution, the valuelist shows no records

Thanks in advanced,

Andres

Re: Valuelists based on data

PostPosted: Fri Jan 03, 2014 9:38 am
by jdbruijn
add clientes_vl.loadrecords() to your service solution to make sure there is data in the foundset.

Re: Valuelists based on data

PostPosted: Tue Jan 07, 2014 4:08 pm
by andres.achiary
thanks, jos! that did it