Valuelists based on data

Home for older / inactive topics

Valuelists based on data

Postby vincentc » Mon Feb 18, 2013 11:17 am

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.
vincentc
 
Posts: 56
Joined: Thu Aug 25, 2011 11:12 am

Re: Valuelists based on data

Postby sanneke » Mon May 06, 2013 5:22 pm

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, [])
Sanneke
Yield Software Development: Need help on your project?
yieldsd.com
User avatar
sanneke
 
Posts: 383
Joined: Thu Jun 15, 2006 9:20 am
Location: Amersfoort

Re: Valuelists based on data

Postby vincentc » Tue May 07, 2013 11:20 am

Thank you very much for your answer ! I will try this soon and I will let you know
vincentc
 
Posts: 56
Joined: Thu Aug 25, 2011 11:12 am

Re: Valuelists based on data

Postby vincentc » Wed May 29, 2013 10:12 am

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
vincentc
 
Posts: 56
Joined: Thu Aug 25, 2011 11:12 am

Re: Valuelists based on data

Postby sanneke » Thu May 30, 2013 2:31 pm

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
Sanneke
Yield Software Development: Need help on your project?
yieldsd.com
User avatar
sanneke
 
Posts: 383
Joined: Thu Jun 15, 2006 9:20 am
Location: Amersfoort

Re: Valuelists based on data

Postby vincentc » Tue Jun 04, 2013 2:32 pm

Thank you !
vincentc
 
Posts: 56
Joined: Thu Aug 25, 2011 11:12 am

Re: Valuelists based on data

Postby andres.achiary » Thu Jan 02, 2014 7:14 pm

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
andres.achiary
 
Posts: 12
Joined: Fri Aug 31, 2012 5:42 pm

Re: Valuelists based on data

Postby jdbruijn » Fri Jan 03, 2014 9:38 am

add clientes_vl.loadrecords() to your service solution to make sure there is data in the foundset.
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 492
Joined: Sun Apr 11, 2010 6:34 pm

Re: Valuelists based on data

Postby andres.achiary » Tue Jan 07, 2014 4:08 pm

thanks, jos! that did it
andres.achiary
 
Posts: 12
Joined: Fri Aug 31, 2012 5:42 pm


Return to Archive

Who is online

Users browsing this forum: No registered users and 2 guests