Trigger dynamic list reload when another config value change

Posted on
Mon Jul 30, 2018 8:57 pm
jheddings offline
User avatar
Posts: 149
Joined: Dec 01, 2013
Location: Denver, CO

Trigger dynamic list reload when another config value change

I'm sure this has been covered elsewhere on the forum, but I have not been able to find it by searching...

On a config dialog for a device, I have 2 lists. I need to generate the content for the 2nd list after a selection changes in the first list. For example, if I have a list of states and a list of cities, I want to refresh the cities anytime the state changes. The dynamicReload parameter only triggers when another callback is used, so I can make a button that calls a stub method, but it isn't great from the user's perspective and can lead to invalid state / city combinations.

Code: Select all
<Field type="menu" id="state">
  <Label>State</Label>
  <List>
    <Option value="az">Arizona</Option>
    <Option value="co">Colorado</Option>
    <Option value="ca">California</Option>
  </List>
</Field>
<Field type="menu" id="city">
  <Label>City</Label>
  <List class="self" method="listCurrentCities" dynamicReload="true" />
</Field>


Any suggestions?

Posted on
Mon Jul 30, 2018 9:09 pm
jheddings offline
User avatar
Posts: 149
Joined: Dec 01, 2013
Location: Denver, CO

Re: Trigger dynamic list reload when another config value ch

Never mind... I think I found a good workaround. Setting the callbackMethod of the menu to a dummy callback method seems to do the trick:

Code: Select all
<Field type="menu" id="state">
  <Label>State</Label>
  <List>
    <Option value="az">Arizona</Option>
    <Option value="co">Colorado</Option>
    <Option value="ca">California</Option>
    <CallbackMethod>forceConfigCallback</CallbackMethod>
  </List>
</Field>
<Field type="menu" id="city">
  <Label>City</Label>
  <List class="self" method="listCurrentCities" dynamicReload="true" />
</Field>


If there are other options, I'd be glad to hear them.

Posted on
Tue Jul 31, 2018 5:58 am
DaveL17 offline
User avatar
Posts: 6756
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Trigger dynamic list reload when another config value ch

I use dummy callbacks to do this too.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Jul 31, 2018 9:42 am
jay (support) offline
Site Admin
User avatar
Posts: 18221
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Trigger dynamic list reload when another config value ch

Yep, callbacks that do nothing FTW in that scenario. Though, I think you have it specified in the wrong place in the XML above (it should be outside of the <List> element, right?).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Jul 31, 2018 9:45 am
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Trigger dynamic list reload when another config value ch

Built into almost every one of my plugins with more than a typical 4 field UI:

Code: Select all
<CallbackMethod>do_nothing</CallbackMethod>


That calls a function that serves no other purpose than to be the catalyst for dynamic lists to refresh ;).

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 9 guests