Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Document Type fields e.g. multiple checkbox View modes: 
User avatar
Certified Developer v7
Certified  Developer v7
Gitesh - 2/11/2013 10:45:19 PM
   
Document Type fields e.g. multiple checkbox
HI Guys,

I have created a multiple checkbox with values as below:
1; Product1
2; Product2
3; Product3

On the backend(CMSDESK) it shows the following checkbox values:
Product1
Product2
Product3

But on the frontend it shows:
1|2|3

Any ideas how to get the values as below on the frontend:
Product1|Product2|Product3

Thanks
Gitesh Shah

User avatar
Kentico Support
Kentico Support
kentico_janh - 2/12/2013 2:19:17 AM
   
RE:Document Type fields e.g. multiple checkbox
Hello,

You can even define your multiple choice checkboxes as below:
Product1; Product1
Product2; Product2
Product3; Product3

Or you can write you own macro method/transformation function (depends on where you render those data) and return appropriate values instead of IDs.

Best regards,
Jan Hermann

User avatar
Certified Developer v7
Certified  Developer v7
Gitesh - 2/12/2013 6:00:54 PM
   
RE:Document Type fields e.g. multiple checkbox
Hi Jan,

Thanks for your reply.

We cannot go with the first solution as the checkbox field is getting values with the SQL query as below:
Select IDS, ProductName FROM TableName;

We have got like approx 300 items in the checkbox. I am happy to write a transformation function / custom macro.

So would there be a way to dynamically get the values in transformation function for the ids? Like do we need to check with the field that is stored in the database?

Any ideas/example would be appreciated?

Thanks
Gitesh Shah

User avatar
Kentico Support
Kentico Support
kentico_janh - 2/13/2013 7:25:02 AM
   
RE:Document Type fields e.g. multiple checkbox
Hello,

You can change your SQL script to "Select ProductName, ProductName FROM TableName;"

However if you decide to implement your own transformation function, then you can just call it with the ID parameter and this function returns its text value instead.

http://devnet.kentico.com/docs/devguide/index.html?adding_custom_functions_to_transformations.htm

Best regards,
Jen Hermann

User avatar
Certified Developer v7
Certified  Developer v7
Gitesh - 2/13/2013 10:38:09 PM
   
RE:Document Type fields e.g. multiple checkbox
Hi Jen,

If I use the first method, and if the client changes the ProductName to some thing else than all the selection for that product are lost. So it would be worth using the ProductID as the join and showing ProductName on the frontend as the result.

I have started creating a transformation function but I am still missing something:
My Transformation Function code:

public static string ReplaceWithValues(object id)
{
// Checks that text is not null.
if (id == null | id == DBNull.Value)
{
return "";
}
else
{
string idString = (string)id;
return idString;
}
}


Code which calls the function from a transformation:

<%# CustomCode.ReplaceWithValues(Eval("Site")) %>


It is still showing the ID's and not the values. Any ideas what am I missing?

Thanks
Gitesh Shah

User avatar
Kentico Support
Kentico Support
kentico_janh - 2/19/2013 7:44:05 AM
   
RE:Document Type fields e.g. multiple checkbox
Hello,

You need to return the value instead of ID, so your code needs to look like this:

public static string ReplaceWithValues(object id)
{
string value = "";
// Checks that text is not null.
if (id == null | id == DBNull.Value)
{
return value;
}
else
{
<select product by ID using API or directly from DB>
value = <product.name>
return value;
}
}


Best regards,
Jan Hermann