Dev Space

Customize and extend the power of Alteryx with SDKs, APIs, custom tools, and more.
SOLVED

HTML SDK - How to set the NumericSpinner default value?

cam_w
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?

3 REPLIES 3
patrick_digan
17 - Castor
17 - Castor

@cam_w  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> 

 

cam_w
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!