Page 1 of 2

Display different columns from DB Service, depending on the application language selected

Posted: Fri Apr 22, 2016 12:55 pm
by Takis

Hello

I have an app that displays a menu (check boxes) of selections on the first page.
The labels of the check boxes are stored on the database.
I created a service that get these values from database and works fine.
I want to create another column in the database, that will contain the same labels but in different language.

When user selects the preferred language, the value will be stored in a local parameter.

Is there a way to do this within the same service?
I have an already working service, can I modify it to add other columns/fileds to be mapped and not start from zero?

Thanks a lot team!


Display different columns from DB Service, depending on the application language selected

Posted: Fri Apr 22, 2016 1:58 pm
by Takis

Previous reply from you was

===================

EMPLOYEE
Yurii Orishchuk (Employee) 1 year ago
Hi Panagiotis,

Here is a brief plan:

1 Make link from $ object to table. To iterate it. http://prntscr.com/57h3zn/direct

2 Click on "JS" on this link.

3 Populate it with following JS code: http://prntscr.com/57h48k/direct

var currentLanguage = localStorage.getItem("mylangSelection");
console.log("currentLanguage = " + currentLanguage);
//Link message to collumn name.
var langColumnMapping = {
"en": "Offer_en",
"gr": "Offer_gr"
};
//Get language column name;
var goalColumnName = langColumnMapping[currentLanguage];
console.log("goalColumnName = " + goalColumnName);
//Get language column value.
var goalColumnValue = value[goalColumnName];
console.log("goalColumnValue = " + goalColumnValue);
//Save goal value to goal component.
element.find('[name="labelName"]').text(goalColumnValue);

That's all.

Note: given code has comments, please read them to understand how this code works step-by-step.

Regards.


Display different columns from DB Service, depending on the application language selected

Posted: Fri Apr 22, 2016 1:58 pm
by Takis

Display different columns from DB Service, depending on the application language selected

Posted: Fri Apr 22, 2016 2:01 pm
by Takis

I have the above current mapping.

How is your previous code applies to this case?
Should I remove all mappings and leave only the top one?

I would like to have, TopMenu and SubMenu (gr, en) selection based on what the user selected.


Display different columns from DB Service, depending on the application language selected

Posted: Fri Apr 22, 2016 3:33 pm
by Serhii Kulibaba

Hello,

You are able to use collection name as a dynamic URL parameter of the service: https://devcenter.appery.io/documenta...
according to the selected language


Display different columns from DB Service, depending on the application language selected

Posted: Fri May 20, 2016 11:40 am
by Takis

Hi

I used the below code for testing
=================================
var currentLanguage = "gr";
//localStorage.getItem("mylangSelection");

//Link message to collumn name.
var langColumnMapping = {
"en": "TopMenu_en",
"gr": "TopMenu_gr"
};
//Get language column name;
var goalColumnName = langColumnMapping[currentLanguage];

//Get language column value.
var goalColumnValue = value[goalColumnName];

//Save goal value to goal component.
//element.find('[name="InterestCheckbox"]').text(goalColumnValue);

element.find('[name="InterestsColabsibleHeader"]').text(goalColumnValue);
=================================

The JS is on the point showed in the picture Image


Display different columns from DB Service, depending on the application language selected

Posted: Fri May 20, 2016 11:43 am
by Takis

When I run it I see this

Image

So text is shown in Greek correctly, but the text does not go in the

InterestsColabsibleHeader text, in order to be able to see it as a checkbox, as it should


Display different columns from DB Service, depending on the application language selected

Posted: Fri May 20, 2016 3:27 pm
by Serhii Kulibaba

It is related with mappings from the English collection. Please remove them: Image
And set the value to the checkbox with JS code, the same as you use for the checkbox text


Display different columns from DB Service, depending on the application language selected

Posted: Mon May 23, 2016 9:13 am
by Takis

I have a two level menu

One level with TopMenu_xx
and below each TopMenu_xx I have the SubMenu1_xxx

So the first level is not displayed correctly as a collapsible Header Image


Display different columns from DB Service, depending on the application language selected

Posted: Mon May 23, 2016 9:14 am
by Takis

This command seems is not the correct one
element.find('[name="InterestsColabsibleHeader"]').text(goalColumnValue);

As currently the top menu is not displayed correctly.
The mappings you told me to delete is related to the second level menu.
Afterwards of course the second level, should be fixed inside the JS, but we are not there yet...!