Deselect GridView Item

Hi,
I have a gridview that is fed its contents (ItemsSource) through an attribute payload i.e. @Device.SupportedMenuItems. It then has a SelectedValue bound to an attribute @Device.MenuItem. It works great. Click an item, it pushed the value into MenuItem, which triggers stuff.

Here’s my problem. It also “selects” that item. Which means I can’t click it again. So I’d really like to deselect the item immediately after it does its stuff.

How might I do this? My system has no knowledge of the items in ItemsSource as they are fed by MQTT.

Hope that makes sense.
Thanks.

Try clearing the MenuItem attribute after you send the command. Writing something to that attribute should trigger a refresh to the GridView & clear your selection. If that doesn’t work, I might have to look at maybe adding a new property to the control so it doesn’t retain the selection.

1 Like

Hi,

just getting back into HR and am stuck implementing the above suggestion.

  1. in an onchange event of my plugin, I have tried device.MenuItem="" - but that does nothing.
  2. I tried creating a datatrigger in the control itself, that gets triggered by Binding @Device.MenuItem with a value of .*, but the only thing I can set in Setters is the GridView properties…so I tried setting, SelectedValue to “”, but that does nothing too.

I’m sure I’ve just forgotten what to do!

Help!

Instead of an empty string try an actual value like say “Unknown” or “-1”.

Also, I do not know if any of this will work. The control was designed to be a selection control. I’m just giving you things to try. As I said, I may have to add a new property to change the behavior of it.

Hi,

Tried that. Didn’t work. But I should be able to set device.MenuItem in my plugin OnChange code - shouldn’t I? Or maybe the value isn’t set until that function is completed.
mmh if that’s the case, then maybe returning “false” from OnChange, should stop the variable assignment (just tried it - didn’t work – but my an idea?).

s.

Whichever way you think is best would be great. I can’t think of a workaround!

I will look into it. I don’t know that I have a workaround for you either at this time.

Thanks. By the way – is there an equivalent of “setTimeout” available.
I am wondering if I could trigger a setTimeout (i.e. non blocking delay) and reset the device.MenuItem variable.
Thx Bill.

There is not “setTimeout” or an equivalent. I’ll try to find you a solution next week.

I looked into this a little closer & the way this is currently set up is that the GridView will retain the selected value for 30 seconds. After 30 seconds it’ll revert back to the actual value & assume the request failed.

This behavior is bypassed for capabilities that are command only, no state information. If you use the MediaControl capability and its SupportedMediaCommands & MediaCommand attributes you should get the behavior you desire.