Hide subset of configuration based on value of a parameter

Hi
How do I selectively display subsets of configuration based on value of a parameter?
I was using “when” statement but confd seem to be deleting the those configuration subsets when the parameter was set to other than that value.
I want to have the all the data to be in the database however would like to display only relevant part based on the parameter.
Wondering if there is any other way or if I am missing something?

Here is an example:
mode has two values: aggregated, differentiated.
cos-classifier has to be shown/available only when mode was set to differentiated.
leaf mode {
type cndlp-types:cndlp-link-mode;
tailf:info “Mode of operation for traffic treatment (aggregated|differentiated)”;
}

  leaf cos-classifier {
      when "../mode = 'differentiated'";
      type cndlp-types:cndlp-classifier-mode;
      tailf:info "Mode of traffic treatment based on vlan or pcp";
  }

I set the config with mode to be differentiated and cos-classifier with some value.
Now, when I change mode to aggregated, as I have when statement, I dont see cos-classifier in cli.
But when switch back the mode to be differentiated I want cos-classifier back. But I wont see it anymore. Looks like confd is deleting cos-classifier record from its database. How to avoid confd to delete cos-classifier but let its rendered cli to display it only when mode was set to differentiated?

You can use the tailf:display-when YANG annotation to control whether a data node should be displayed in CLI and WebUI or not. Refer to vol. 5 of the man pages in the tailf_yang_extensions section for more information on how to use this annotation.

@waitai, Thanks! I hope this extension wont delete the records from the database when the parameter value is switched.

@waitai
How to use tailf:hidden-when??
You said “Refer to vol. 5 of the man pages in the tailf_yang_extensions” Is it confd user guide?

“man page” is a short for “manual page”.

ConfD man pages come as standalone documentation and are also attached as appendixes in the ConfD UG.

As Wai wrote, just search for “tailf:display-when” (not “hidden-when”) in the UG or tailf_yang_extensions(5) man page.

I am not sure what I am missing here but when I used display-when, I am not seeing some config.
Another leaf was working fine. But the list config is not working for display-when.

Both cos-config and pcp-map are conditionlized for display based on mode being differentiated. But I dont see either of them even though both of them were in confd database.

cos-classifier, which was also conditionalized was being displayed when mode was set to differentiated; and dont when mode was set to aggregated. Not sure what is missing for list parameters…

container link {
tailf:info “Traffic treatment”;

  list cos-config {
     tailf:display-when "../mode = 'differentiated'";
     key cos;
     max-elements 8;
     tailf:info "Cos configuration per cos";

     leaf cos {
         type cndlp-types:cndlp-cos-id;
         tailf:info "cos (0..7)";
     }
 } 
 list pcp-map {
      tailf:display-when "../mode = 'differentiated'";
      key cos;
      tailf:info "Map cos to a pcp-id";

      leaf cos {
         type cndlp-types:cndlp-cos-id;
         tailf:info "cos (0..7)";
      }
 }
 leaf mode {
      type cndlp-types:cndlp-link-mode;
      tailf:info "Mode of operation for traffic treatment [aggregated|differentiated]";
  }
 leaf cos-classifier {
      tailf:display-when "../mode = 'differentiated'";
      type cndlp-types:cndlp-classifier-mode;
      tailf:info "Mode of traffic treatment based on vlan or pcp";
  }

}

I used absolute path and the issue is fixed.