Display records as comma separated

Is it possible to display the foundset records as comma separated instead of default line by line?.

Though I want to display the comma separated records in portal, it could be anywhere else too. Please suggest.


shaikna

records comma separated? please clarify

Yes, comma separated records.

For example, if I have a “country” table and “country name” is one of the field, what I want is to list all the “country name” (just one field) as comma separated instead of line-by-line.

How do I achieve this?.


shaikna

Hi Shaikna,

I think you want achieve similar to the following

  1. You have a master table say Contacts

  2. You have a history table where you store all the interests(category) of the contacts

Say Mr.John has interest records as Cricket & Rugby etc..

In the contact form you can display the interests stored in the history table using portal.

Here instead of portal you want to show them as comma seperated values so that you can save some space in the layout

If the above was the scenario you can use the following trick which we use in FMP

  1. Create a relationship between Contacts & history using the key field contact_id

  2. Create a value list based on the above relation (you will get the values similar to what you get in portal)

  3. Now create a calculated field with the following

i) Get the values of the value list using the available function in servoy. This will give you only the related values (enter seperated)

ii) Using the function Replace the enter chars with comma

iii) Now your values would be (Rugby, Cricket)

Make sure that the calculation is unstored

Servoyians!! Any other easy way??

Thanks
Ahmad
Hong Kong

Thanks Ahmad for your input.
Based on your example here’s another way(leave out the valuelist)
create an unstored calc:
(this example creates a string with all order id’s based on the company_to_orders relation
var result = “”;

for(var i=1 ; i <=companies_to_orders.getMaxRecordIndex() ; i++)
{
	companies_to_orders.recordIndex = i
	result += companies_to_orders.ordersid+",";
}

result = result.substring(0 , result.length-1);//remove last comma
return result;

you can attach your unstored calc to a label, button, tooltiptext or whatever. (instead of comma’s, throw in some html to control the look of your result. bg color, font, table etc…)

Thanks maarten, it works perfectly.. fantastic.