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

This forum contains topics that were moved from Get Satisfaction
Takis
Posts: 0
Joined: Wed Oct 22, 2014 5:10 pm

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

Post by Takis »

Can you please help me with this question?
Thanks!

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

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

Post by Serhii Kulibaba »

In that case you can save responses of services to the storage variable, and use that variable in the final mapping. Before mapping you can change that variable as you want, but it is impossible to use two different mappings to the same component - it will be re-writed by the very last mapping, so, previous one won't be able

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

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

Post by Takis »

Sorry, I am not sure I was clear

I have
Collapsible block header which maps to database column TopMenu1_en or TopMenu1_gr

Inside the CollapsibleBlock I have checkboxes, which maps to database column SubMenu_en or SubMenu_gr

When I choose language "en", I want to dynamically change the mapping and have

  1. Collapsible block header text from db columnTopMenu1_en and

  2. Checkboxes text from db column SubMenu_en

    This is not possible (change dynamically the mapping)?
    I used the code in the Success event. Is this correct?

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

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

Post by Takis »

When I use the JS code, the result is the below

Image

When I do the mapping without the JS code (not dynamic mapping) it is displayed properly

Image

So I suspect that we are missing something in the JS code below:
================================
element.find('[name="InterestsColabsibleHeader"]').text(goalColumnValue);
=================================

Thanks!

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

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

Post by Serhii Kulibaba »

No, it is impossible to use dynamic mapping

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

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

Post by Takis »

Can you explain why the JS code has the effect shown in the last two pictures uploaded please?

Thanks.

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

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

Post by Serhii Kulibaba »

If you use JS on the mapping (https://devcenter.appery.io/documenta...) you are able to change the object "element" there. This is a currect element of the mapping (listitem, grid, label, etc.)
Appery.io generates new components automatically, so if you change a parent component it will change also all it's children.

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

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

Post by Takis »

Sorry is not very clear.

I am trying to dynamically change the text of the Collapsblock header, to show either Greek or English, depending on a local variable.

So I have the JS code in the top level as seen below, as you told me

Image

The text of the header is changed properly, but I loose the "look" of the collapsible block, is displayed as just text. (see above 2 last images)

Should I put a code in somewhere else?
Should the below code be different?
================================
element.find('[name="InterestsColabsibleHeader"]').text(goalColumnValue);
=================================
so we do not loose the "look" of collapsible bock?

Thanks and sorry for the continuing questions

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

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

Post by Serhii Kulibaba »

It looks fine. But as I said before - it is better to save the response with selected language to the storage variable (https://devcenter.appery.io/documenta...)
pre

var result = [];
$.each( data.results, function( key, value ) {
value.TopMenu = (language === "en") ? value.TopMenu_en : value.TopMenu_gr;
value.SubMenu = (language === "en") ? value.SubMenu_en : value.SubMenu_gr;
result.push(value);
});
Apperyio.storage.result.set(result);/pre

here language - selected language ("en" or "gr")

result - name of the Storage variable with the structure=service response + additional parameters TopMenu and SubMenu

And use that variable in the simple mapping (using columns TopMenu and SubMenu).

TopMenu and SubMenu - values of TopMenu and SubMenu, according to the selected language

I can't describe it more detailed - unfortunately this is something outside the scope of standard Appery.io platform support. You may consider purchasing Advisory Pack to get more in-depth help on this question. Here is more information about Advisory Pack (http://appery.io/services/#Advisory_Pack).

Post Reply