Dev Space

Customize & extend the power of Alteryx. SDKs, APIs, custom tools, and more!

General Discussions has some can't miss conversations going on right now! From conversations about automation to sharing your favorite Alteryx memes, there's something for everyone. Make it part of your community routine!

SOLVED

HTML SDK - How to set the NumericSpinner default value?

c2willis
11 - Bolide

My custom tool requires a numeric input for which I'd like to use a NumericSpinner UI element. It worked just fine with the ConstrainedInt Data Item, and I'm using a min, max, and step values to control the user interaction nicely.

 

However, I can't seem to see how to set the default value. The NumericSpinner API documentation shows only the tabIndex is configurable. The HTML GUI SDK Supported Data Items documentation says that ConstrainedInt has a default value of zero (depending on min and max values it appears), but that we can register a 'listener' for the 'value' property. However, the ConstrainedInt API documentation does not show 'value' as part of the constructor or expose set/get for this property.

 

I can see the 'value' using the CEF debug tool, but this is 'too late' as the tool has already run to create the HTML interface. I need to set the default 'value' in the 'BeforeLoad' javascript function.

 

Is there a way to do this? Would I have to set the min to my default value, then run an AfterLoad function to set the min back to the true min?

patrick_digan
16 - Nebula
16 - Nebula

@c2willis  Does @NeilR 's post to this challenge help? Here was his comment, note the script piece at the end.

<div class="widgetLabel">Z</div>
<ayx data-ui-props='{type:"NumericSpinner", widgetId:"z_spinner"}' data-item-props='{dataName:"z_spinner", dataType:"SimpleFloat", value:"1"}'></ayx>

<div class="widgetLabel">Field to test</div>
<ayx data-ui-props='{type:"DropDown", widgetId:"field_dropDown"}' data-item-props='{dataName:"field_dropDown", dataType:"FieldSelector"}'></ayx>

<script>
  Alteryx.Gui.BeforeLoad = function (manager, AlteryxDataItems, json) {
    manager.getDataItem('z_spinner').setValue(3)
  }
</script> 

 

c2willis
11 - Bolide

@patrick_digan- Yes, yes it does! 🙂 Thanks for the quick reply!

 

This was one of those issues that I should have just pressed on a little bit more ... because as soon as I posted my question, I switched over to the Console tab of the CEF I found the 'getDataItem()' of the manager and saw that I could invoke the setValue() method from there.

 

My final solution that work is below, where the 'LogicalRecordLength' string was the name of the new AlteryxDataItems.ConstrainedInt():

 

manager.getDataItem('LogicalRecordLength').setValue(47)

 

RuchikaMangla
8 - Asteroid

Hi @patrick_digan ,

 

Do you know how to set it's value in afterLoad function? Because I am using a drop down and based on a specific value selected in drop-down it unhides 2 numberspinners. But it is throwing error saying dataitemcontainers are not allowed in macro mode. As Engine of this tool is macro only.

 

Please let me know if you have any suggestion here. Thanks in advance!