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

Return specific column based on language selected

Hi team

Suppose I have a table with Offers and has columns that displays the offers in different languages, like Offer_gr, Offer_fr, Offer_eg, Offer_it

Lets say that user selects a language from a "settings" page and I store the value to a local storage variable.

Then I want to create a query service to display dynamically the Offer column, that corresponds to the language chosen.
Can this be done?

Thanks!

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Return specific column based on language selected

Hello Panagiotis,

Of course. You may either make the mapping of all columns and hide elements that you do not need to show on success of the service. Or you may fill the element's value with the desired value of response using js code http://devcenter.appery.io/documentat...

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

Return specific column based on language selected

Hi Evgene

The fist option looks it would use unwanted resources and data, but is an option of course.

For the second option, I read but I could understand how this can be done.
Can you give me a simple example/screen shot please?

Lets say I have local storage variable "mylangSelection" ,a table that has multiple columns Offer_gr and Offer_en and one label "offer_label" in the mobile application where I want to display the related value.

Thanks.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Return specific column based on language selected

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

pre

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);

/pre

That's all.

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

Regards.

Return to “Issues”