Takis
Posts: 0
Joined: Wed Oct 22, 2014 5:10 pm

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

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!

Takis
Posts: 0
Joined: Wed Oct 22, 2014 5:10 pm

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

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.

Takis
Posts: 0
Joined: Wed Oct 22, 2014 5:10 pm

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

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.

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

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

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

Takis
Posts: 0
Joined: Wed Oct 22, 2014 5:10 pm

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

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

Takis
Posts: 0
Joined: Wed Oct 22, 2014 5:10 pm

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

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

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

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

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

Takis
Posts: 0
Joined: Wed Oct 22, 2014 5:10 pm

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

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

Takis
Posts: 0
Joined: Wed Oct 22, 2014 5:10 pm

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

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...!

Return to “Issues”