set valueList items from a custom list with multiple returns

Questions, tips and tricks and techniques for scripting in Servoy

set valueList items from a custom list with multiple returns

Postby paulc » Thu Jul 22, 2010 9:25 pm

Is it possible to set a custom value list to return multiple values?

Currenty I have code that loops through all of the elements on a page and then sets up an array of display values, and an array of arrays that has element name and its dataprovider type.

This currently works, the issue I am having now is when the user selects a value, the value returned is something like "[Ljava.lang.Object;@99c1c2". Any ideas on how to make the array return the proper values?

Code: Select all

  for ( var i = 0 ; i < form.elements.allnames.length ; i++)
  {
    lv_elementName = form.elements.allnames[i]; 
    lv_element = form.elements[lv_elementName];
   args = lv_elementName.split('_');

    if(args[0] == 'fld')
    {
      lv_searchFieldDisplay.push(lv_element.getTitleText());
     
      var lv_dataProvider = lv_element.getDataProviderID().split('.');
      var lv_dataProvider_table = new Array();
      (lv_dataProvider.length > 1)?lv_dataProvider_table = lv_dataProvider[0].split('_to_'):lv_dataProvider_table.push(databaseManager.getTable(form.foundset).getSQLName());
     
      lv_searchFieldValues.push(new Array(lv_element.getName(),databaseManager.getTable(globals.security_current_database_server, lv_dataProvider_table[lv_dataProvider_table.length - 1]).getColumn(lv_dataProvider[lv_dataProvider.length - 1]).getTypeAsString()));
    }
  }

application.setValueListItems("vl_Fields", lv_searchFieldDisplay,lv_searchFieldValues);



Thanks
paulc
 
Posts: 55
Joined: Wed Feb 17, 2010 8:58 pm

Re: set valueList items from a custom list with multiple returns

Postby jcompagner » Mon Jul 26, 2010 10:15 am

if you give the valuelist a array as return value
Then the dataprovider must be a media field (so not a string or number)

then you should be able to ask the dataprovider value in scripting and threat it as an array.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: set valueList items from a custom list with multiple returns

Postby paulc » Tue Jul 27, 2010 11:57 pm

Okay..just to clarify before I get started.

Create a form level variable and use it as the dataprovider for the combobox
Code: Select all
* @properties={typeid:35,uuid:"5A9C477E-3F30-4E76-8DB0-9DF44EFAEEC8",variableType:-4}
var fv_testMedia = new Array();


OnShow will call my method which will do the following
Code: Select all
  var form = forms[lv_form_name];
 
  var lv_elementName = '';
  var lv_element;
  var args = '';
  var lv_searchFieldDisplay = new Array;
  var lv_searchFieldValues  = new Array;
 
  for ( var i = 0 ; i < form.elements.allnames.length ; i++)
  {
    lv_elementName = form.elements.allnames[i]; 
    lv_element = form.elements[lv_elementName];
   args = lv_elementName.split('_');

    if(args[0] == 'fld')
    {
      lv_searchFieldDisplay.push(lv_element.getTitleText());
     
      var lv_dataProvider = lv_element.getDataProviderID().split('.');
      var lv_dataProvider_table = new Array();
      (lv_dataProvider.length > 1)?lv_dataProvider_table = lv_dataProvider[0].split('_to_'):lv_dataProvider_table.push(databaseManager.getTable(form.foundset).getSQLName());
   
      //Test array for the dataProvider   
      lv_searchFieldValues.push(new Array(lv_element.getName()));
    }
  }

  //Set Value List Items
  application.setValueListItems("vl_searchColumns", lv_searchFieldDisplay,lv_searchFieldValues);


I tried the code above, and although there are no errors, the "display" values are just repeating the first value in that list. So my screen has 15 fields, both arrays do have 15 values, but the combobox is only displaying the very first value of the "display" array 15 times.

I know I'm missing something here...any ideas?

thanks
paulc
 
Posts: 55
Joined: Wed Feb 17, 2010 8:58 pm

Re: set valueList items from a custom list with multiple returns

Postby jcompagner » Wed Jul 28, 2010 9:59 am

hard to say, it is something we dont directly support.

so place make a feature request case with a small example what you try to do.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet


Return to Methods

Who is online

Users browsing this forum: Google [Bot] and 5 guests

cron