cancel
Showing results for 
Search instead for 
Did you mean: 

Function on contribution.ztl not working

former_member183473
Participant
0 Kudos

   Hi experts,

I'm having a problem, on the contribution.ztl file, I created the following code

String getSelectedValue(){*

  return this.selectedValue;

  *}

Which I fire when the value is changed on the combobox, with the following code.

that.setProperty("selectedValue",that.getValue());

  that.fireDesignStudioPropertiesChanged(["selectedValue"]);

  that.fireDesignStudioEvent("onchange");

But it always return undifined when I try to show the result of the function getSelectedValue.

My code is here

https://github.com/olafecorcam/com.leandro.gp.combobox

Any ideas?

By the way, this component I'm creating so that I can add "ALL" to the list of values inside the combo, as per now the native one comes with the first value already selected, which is causing confusion on the users.

Best

Leandro

Accepted Solutions (1)

Accepted Solutions (1)

mike_howles4
Active Contributor
0 Kudos

Add this property in contribution.xml:


<property type="String" id="selectedValue" title="Selected Value (Needed whether you want it in a property sheet or not)" visible="false"/>


Also, change this code snippet in component.js:


initDesignStudio : function() {

  try {

  var that = this;

  this.attachChange(function() {

  alert(that.getValue());

  // Do this:

  that.setSelectedValue(that.getValue());

  // Not this:

  // that.setProperty("selectedValue",that.getValue());

  that.fireDesignStudioPropertiesChanged(["selectedValue"]);

  that.fireDesignStudioEvent("onchange");

  });

  } catch (e) {

  alert(e); // Aw snap

  }

There, fixed. 

Answers (1)

Answers (1)

IngoH
Active Contributor
0 Kudos

Hello Leandro,

just as a quick check on this comment here:

--------

By the way, this component I'm creating so that I can add "ALL" to the list of values inside the combo, as per now the native one comes with the first value already selected, which is causing confusion on the users.

-------

You are aware that the setItems option does have an option to add "ALL" to the list of items ?

regards

Ingo Hilgefort

mike_howles4
Active Contributor
0 Kudos

Ingo, please explain, because the BIAL syntax isn't helping show how.

IngoH
Active Contributor
0 Kudos

just put a "ALL" as last item for the setItems command.

example:

DROPDOWN_2.setItems(DS_1.getMemberList(<dimension>, MemberPresentation.INTERNAL_KEY, MemberDisplay.TEXT, 20,"All"));

Ingo

mike_howles4
Active Contributor
0 Kudos

So technically not part of the setItems options, but rather the getMemberList options, then.  Got it, thanks.

former_member183473
Participant
0 Kudos

I did not now that one...

Well that was an entire day for nothing hahahaha...

But I'll get to keep the knowledge..

And Michael, your solution worked like a charm.. thank you.

Best

Leandro

mike_howles4
Active Contributor
0 Kudos

Leandro,

I was also surprised.  I'm guessing it's not enough to rely on the autocomplete functionality in the Script Editor window, because it looks like it only will put in mandatory parameter placeholders, so I understand how it's not completely obvious:

former_member183473
Participant
0 Kudos

Ingo,

Thanks for the tip, but now I came across another problem.

I'm using the native dropdown now, and there's 4 of them, and I created a button that clear all applied filters, I can't set the combo value back to "All".. I

tried

DP_RAMO.setSelectedValue("");

DP_RAMO.setSelectedValue("All");

DP_RAMO.setSelectedValue("(ALL_MEMBERS)");

But none of it worked.

Can you help me?

Best

Leandro

former_member183473
Participant
0 Kudos

Yep, from now on I'll take a better look into the help tooltip of the functions.

Thanks again.

Best

Leandro

IngoH
Active Contributor
0 Kudos

did you try a clearallfilter?

Ingo

former_member183473
Participant
0 Kudos

Ingo,

I'm able to clear the filters on the data sources, I'm not able to set the value "All" back to the dropdown box.

Best

Leandro

mike_howles4
Active Contributor
0 Kudos

Can you clear the filter and then re-issue the same setitems statement again?  Maybe that order of events will force the dropdown back to 'All'?

IngoH
Active Contributor
0 Kudos

that should for sure do the trick but kind of an unnecessary step. don't have time today to play around but will look into this on Monday

ingo

former_member183473
Participant
0 Kudos

I tried that, and nothing.

What worked was,


DP_MES.setItems(DS_GRAFICO.getMemberList("0PLANT", MemberPresentation.INTERNAL_KEY, MemberDisplay.TEXT, 0,"Todos"));

DP_MES.setItems(DS_GRAFICO.getMemberList("0CALMONTH2", MemberPresentation.INTERNAL_KEY, MemberDisplay.TEXT, 0,"Todos"));

I had to set a different list, and than set the right one back, and that did the trick.

Best

Leandro

mike_howles4
Active Contributor
0 Kudos

LOL, glad you found a combination of commands to knock it into submission for you. 

I'd tend to agree with Ingo that having to do it in this manner is kind of unnecessary but at the end of the day sometimes you must do what works and move on, I suppose!

At least you've come to two options of how to overcome it now!  (BIAL script trickery or an Addon).