format - How to display a nested collection with .ps1xml file in powershell -
i have hierarchical object structure this:
public class department { public string name { get; set; } public string manager { get; set; } public employee[] employees { get; set; } } public class employee { public string name { get; set;} public string speciallity { get; set; } }
how can create custom .ps1xml file let me display department(s)
follows:
department : testers manager : p.h. boss name speciallity ---------- ----------------------------- employee .net employee biztalk yet powershell ... ... department : developers manager : wally name speciallity ---------- ----------------------------- employee .net employee biztalk yet powershell ... ...
the main problem i'm having how can define <view>
item selected department
, based on tablecontrol
, displays department.employees
in table control.
i can display employee
(s) fine using view
:
<view> <name>employee</name> <viewselectedby> <typename>employee</typename> </viewselectedby> <tablecontrol> <tableheaders> <tablecolumnheader> <label>name</label> <width>30</width> </tablecolumnheader> <tablecolumnheader> <label>speciallity</label> <width>50</width> </tablecolumnheader> </tableheaders> <tablerowentries> <tablerowentry> <wrap/> <tablecolumnitems> <tablecolumnitem> <propertyname>name</propertyname> </tablecolumnitem> <tablecolumnitem> <propertyname>speciallity</propertyname> </tablecolumnitem> </tablecolumnitems> </tablerowentry> </tablerowentries> </tablecontrol> </view>
and can format departments using list format:
<view> <name>testresultset</name> <viewselectedby> <typename>department</typename> </viewselectedby> <listcontrol> <listentries> <listentry> <listitems> <listitem> <label>department</label> <propertyname>name</propertyname> </listitem> <listitem> <propertyname>manager</propertyname> </listitem> </listitems> </listentry> </listentries> </listcontrol> </view>
but how add table of employees after department?
i think need make use of <groupby>...</groupby
, <control><customcontrol>...</customcontrol></control>
take @ this ps1xml format file discutils module, haven't had chance play myself yet may put on right path.
see help about_format.ps1xml
has info, though little light on examples aspects.
Comments
Post a Comment