Filters for device page fields

Hello,

We were trying to filter device page fields but not having much luck. We tried doing something like this:

- label: '"WiFi Network Name"'
  parameter: VirtualParameters.WiFi-SSID
  filter: VirtualParameters.Hardware-Type = "MRR"

It doesn’t error out, but it still shows this field for devices where hardware-type is not MRR. Am I putting the filter parameter in the wrong place?

The filter property only works with the container component.

Thanks - Then how can parameters in the parameter-list be filtered? I have some parameters in the parameter-list that only apply to certain types of devices - I am unsure as to how to make those parameters only appear for those devices. Can I put a parameter-list inside a container somehow (or vice versa)?

Try this:

- label: '"WiFi Network Name"'
  parameter: VirtualParameters.WiFi-SSID
  filter: VirtualParameters.Hardware-Type = "MRR"
  type: "'container'"
  components:
    - type: "'parameter'"

This replaces the default component (i.e. parameter) that is used to render each individual value. It replaces it with a container component with which you can use the filter property. The parameter-list component will then skip any item that renders nothing.

I should’ve mentioned this solution in my previous answer but oddly enough it didn’t occur to me until you asked a direct how question :slight_smile:

1 Like

Thanks!

Any similar way that an entire parameter-table could be hidden? For instance, there is the hosts table that doesn’t really apply to devices that aren’t routers - so if the device is not a router, there is a useless “hosts” table that will always be empty taking up vertical space on the device page.

You could put that parameters-table component inside a container component.

1 Like

Thanks, I’ll give that a try - I think I’m starting to get the hang of nesting components.

So when I try changing this:

- label: '"Wireless Radios"'
  parameter: Device.WiFi.Radio
  type: "'parameter-table'"
  childParameters:
    - label: "'Status'"
      parameter: Status
    - label: "'Frequency'"
      parameter: SupportedFrequencyBands
    - label: "'802.11'"
      parameter: SupportedStandards
    - label: "'CCQ'"
      parameter: X_MIKROTIK_Stats.OverallTxCCQ

to this:

- filter: VirtualParameters.Hardware-Type = "MRR"
  label: '"Wireless Radios"'
  parameter: Device.WiFi.Radio
  type: "'container'"
  components: 
    - type: "'parameter-table'"
      childParameters:
        - label: "'Status'"
          parameter: Status
        - label: "'Frequency'"
          parameter: SupportedFrequencyBands
        - label: "'802.11'"
          parameter: SupportedStandards
        - label: "'CCQ'"
          parameter: X_MIKROTIK_Stats.OverallTxCCQ

The device page refuses to load after that - any idea as to what I am doing wrong?

Move the parameter property down to the parameter-table component.

That works, thanks! Why is that different from Filters for device page fields - #4 by zaidka where the parameter property is at the top level? I wasn’t entirely sure why the parameter property was at the top level there and why it is in the parameter-level component in this case.

i.e. why is the solution in post 4 not this:

- filter: VirtualParameters.Hardware-Type = "MRR"
  type: "'container'"
  components:
    - type: "'parameter'"
      parameter: VirtualParameters.WiFi-SSID
      label: '"WiFi Network Name"'

Just curious

In the case of parameter-list, the child components are “contextified” so the parameter arg automatically propagates to the subcomponents. The container component doesn’t do that because it’s just a wrapper and doesn’t add any context to its subcomponents. Hope that makes some kind of sense…

Yes, that does make sense, thanks! I figured with your original response that there was some kind of inheritance involved regarding propagation of settings to the lower levels. So in that case, I assume it might also work as shown in my last post? Or is the solution in post 4 the only one that would work for that?

Correct. The solution in your last post should work too.

1 Like