How to get onyx.Picker value

edited May 2014 in Newbie Questions
How would I go about getting the value of a onyx.Picker (the active content) if I am not using onChange. I am basically making an enter/submit button that I need to collect all the input values and send them off.
enyo.kind({
	name: "inputBody",
	kind: "enyo.Scroller",
	classes: "panel-body",
	components: [
		{content: "Number of Lines", classes: "text-divider"},
		{kind: "onyx.PickerDecorator", components: [
			{classes: "onyx-dark input-box number-size"},
			{name: "lines", kind: "onyx.IntegerPicker", min: 1, max: 10, value: 1}
		]},
		{tag: "br"},
		{kind: "onyx.Button", content: "Calculate", classes: "onyx-dark nice-padding", ontap: "Calculate"}
	],
	Calculate: function(inSender, inEvent) {
		var num = this.$.dataPerLine.content();
		this.doCalculateCarriers(num);
	}
});

Comments

  • edited May 2014
    Try something like this.$.lines.get("value") to retrieve the current value of the picker.
  • edited May 2014
    Nope, undefined value. And to clarify, 'dataPerLine' in that code is referring to another Picker I omitted in the post (forgot to change it to 'lines').
  • When I try this.$.lines.getContent(); I believe I am getting an empty string.
  • Which version of Enyo are you using? Did you try this.$.lines.getValue() instead?
  • I'm using enyo 2.2
    Ok, this.$.lines.getValue(); is working for
    {kind: "onyx.PickerDecorator", components: [
    	{classes: "onyx-dark input-box number-size"},
    	{name: "lines", kind: "onyx.IntegerPicker", min: 1, max: 10, value: 1}
    ]}
    But it isn't working for:
    {kind: "onyx.PickerDecorator", components: [
    	{classes: "onyx-dark input-box"},
    	{name: "minutes", kind: "onyx.Picker", components: [
    		{content: "Minimumal"},
    		{content: 100, active: true},
    		{content: 300},
    		{content: 700},
    		{content: "Unlimited"}
    	]}
    ]},
    They shouldn't be different..
  • Great to hear! The generic get() wasn't available in 2.2.

    For your onyx.Picker try using this.$.minutes.getSelected()
  • edited May 2014
    Thanks for your help. I'm getting the object with getSelected() not the value. Trying different ways to get the value from it now.
  • In this case, would the value just be the content i.e.
    this.$.minutes.getSelected().getContent()
  • Awesome! thanks!
Sign In or Register to comment.