Grid view configuration and what it means

Grid view configuration and what it means

  • Comments 6
  • Likes

Below is a skeleton of how a view definition looks like in a management pack.

 

<View ID="[UniqueViewID]" Target="[TargetClass]" Enabled="true" TypeID="Console!GridViewType" Accessibility="Public">

        <Category>NotUsed</Category>

        <Data>

          <Adapters>

<Adapter>[Data Adapter]</Adapter>

<Adapter>[List Support Adapter]</Adapter>

          </Adapters>

          <ItemsSource>[List Support Class]</ItemsSource>

          <Criteria>[Criteria]</Criteria>

        </Data>

        <Presentation>

          <Columns>[Columns] </Columns>

          <ViewStrings>[View Strings]</ViewStrings>

        </Presentation>

      </View>

 

Here is a detailed explation of what the configuration means:

 

ID is the unique name for the view

Target is the class that you want to target the view to

Enabled is a bool stating whether the view is enabled

Accessibility is whether this view can be referenced from other management packs

TypeID is the view type. We currently have 2 view types out of the box

1.       GridViewType is defined in the console management pack. The configuration is <any> which enables to extend the xml configuration not specified by the schema.  This post talks about grid view configuration

<ViewType ID="GridViewType" Accessibility="Public">

        <Configuration>

          <xsd:any minOccurs="0" maxOccurs="unbounded" processContents="skip" />

        </Configuration>

        <ViewImplementation>

          <Assembly>WpfViewsAssembly</Assembly>

          <Type>Microsoft.EnterpriseManagement.UI.WpfViews.GridView</Type>

        </ViewImplementation>

      </ViewType>

 

2.       OverviewView Type. This is defined in the administration management pack. The configuration again is <any> which

enables to extend the xml configuration not specified by the schema.  The view configuration for this will be discussed later.

<ViewType ID="OverviewType" Accessibility="Public">

        <Configuration>

          <xsd:any minOccurs="0" maxOccurs="unbounded" processContents="skip" />

        </Configuration>

        <ViewImplementation>

          <Assembly>Console!WpfViewsAssembly</Assembly>

          <Type>Microsoft.EnterpriseManagement.UI.WpfViews.Overview</Type>

        </ViewImplementation>

      </ViewType>

 

Data This section defines how the view gets it data. There are 3 areas within the Data that are needed namely Adapters, ItemsSource and Criteria (if needed)

1.       Adapters: There are two adapters needed here, one for the purpose of where is the data fetched from and the other for the List View presentation

a.       Data Adapters: There are again two choices in here.

                    i.      EnterpriseManagementObjectAdapter: If you want instances of a class you would need to use the EnterpriseManagementObjectDataAdapter

            <Adapter AdapterName="dataportal:EnterpriseManagementObjectAdapter">

              <AdapterAssembly>Microsoft.EnterpriseManagement.UI.SdkDataAccess</AdapterAssembly>

              <AdapterType>Microsoft.EnterpriseManagement.UI.SdkDataAccess.DataAdapters.EnterpriseManagementObjectAdapter

</AdapterType>

            </Adapter>

                  ii.      EnterpriseManagementObjectProjectionAdapter: If you want to view projection instances, you would need to use the  EnterpriseManagementObjectProjectionAdapter

            <Adapter AdapterName="dataportal:EnterpriseManagementObjectProjectionAdapter">

              <AdapterAssembly>Microsoft.EnterpriseManagement.UI.SdkDataAccess</AdapterAssembly>              <AdapterType>Microsoft.EnterpriseManagement.UI.SdkDataAccess.DataAdapters.EnterpriseManagementObjectProjectionAdapter

</AdapterType>

            </Adapter>

2.       ListSuppportAdapter: This essentially defines how your data is fetched, at what intervals, etc. Here you can use one of the following

                    i.      ListSupportAdapter: This is less powerful than the one mentioned below.

<Adapter AdapterName="viewframework://Adapters/ListDefault">

 <AdapterAssembly>Microsoft.EnterpriseManagement.UI.ViewFramework</AdapterAssembly>

 <AdapterType>Microsoft.EnterpriseManagement.UI.ViewFramework. ListSupportAdapter</AdapterType>

  </Adapter>

                  ii.      AdvancedListSupportAdapter:

<Adapter AdapterName="viewframework://Adapters/AdvancedList">

 <AdapterAssembly>Microsoft.EnterpriseManagement.UI.ViewFramework</AdapterAssembly>

  <AdapterType>Microsoft.EnterpriseManagement.UI.ViewFramework.AdvancedListSupportAdapter</AdapterType>

  </Adapter>

3.       ItemsSource: This is the place where you specify the ListSupportClass. This needs to go in conjunction with the type of ListSupportAdapter defined above. The ListSupportClass also supports specifying additional parameters that you have for the Data Adapters. The two classes are:

a.        ListSupportClass: If you are using ListSupportAdapter in the Adapters then the corresponding class you’d use is the ListSupportClass.  The ListSupportClass supports the following attributes

<ListSupportClass DataTypeName='' SupportAdapterName='viewframework://adapters/ListDefault' AdapterName= dataportal:EnterpriseManagementObjectAdapter' DataSource='mom:ManagementGroup' IsRecurring='False' xmlns='clr-namespace:Microsoft.EnterpriseManagement.UI.ViewFramework;assembly=Microsoft.EnterpriseManagement.UI.ViewFramework' xmlns:av='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>

    <ListSupportClass.Parameters>

         <QueryParameter Parameter='TargetClass' Value='System.WorkItem.Problem' />

    </ListSupportClass.Parameters>

</ListSupportClass>

Here SupportAdapterName is the ListSuportAdapter name.

AdapterName is the adapter being used to fetch data from sdk.

DataSource is the management group being used. In this case it’s the Service Manager ManagementGroup.

IsRecurring is essentially if the view data can be fetched again after initial fetch

 

b.      AdvancedListSupportClass. This goes with the AdvancedListSupportAdapter. Below is an example of how the definition looks like

 <AdvancedListSupportClass DataTypeName="" AdapterName="viewframework://Adapters/AdvancedList" FullUpdateAdapter="dataportal:EnterpriseManagementObjectProjectionAdapter" DataSource="mom:ManagementGroup" IsRecurring="true" RecurrenceFrequency="{x:Static s:Int32.MaxValue}" FullUpdateFrequency="1" Streaming="true" xmlns="clr-namespace:Microsoft.EnterpriseManagement.UI.ViewFramework;assembly=Microsoft.EnterpriseManagement.UI.ViewFramework" xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib">

              <AdvancedListSupportClass.Parameters>

                <QueryParameter Parameter="TypeProjectionId" Value="$MPElement[Name='System.WorkItem.ProblemViewProjection']$" />

              </AdvancedListSupportClass.Parameters>

            </AdvancedListSupportClass>

Here AdapterName is the AdvancedListSuportAdapter name.

FullUpdateAdapter is the adapter being used to fetch data from sdk.

DataSource is the management group being used. In this case it’s the Service Manager ManagementGroup.

IsRecurring is essentially if the view data can be fetched again after initial fetch

RecurrenceFrequency is the value in milliseconds the view will auto refresh

FullUpdateFrequency value is the # of times of fetch after which a full update of the view will happen

Streaming is bool value to tell whether the view to use streaming (support the data coming in chunks)

 

The ListSupportClass.Parameters are essentially key value pairs of parameters to be sent to the data adapter for data retrieval.

 

The commonly used Parameters for  EnterpriseManagementObjectProjectionAdapter  are:

a)      TypeProjectionId which takes  managementpack element notation as value (so the projection needs to be in a sealed  managementpack or the same managementpack for referencing)

b)      TypeProjectionName which takes the name of the TypeProjection

 

The commonly used Parameters for  EnterpriseManagementObjectAdapter  are:

c)       ManagementPackClassId which takes  managementpack element notation as value (so the class  needs to be in a sealed  managementpack or the same managementpack for referencing)

d)      TargetClass which takes the name of the Class.

 

4.       Criteria This is where you can define any criteria that you might want to have in your view. Example below

<QueryCriteria xmlns="http://tempuri.org/Criteria.xsd" Adapter="omsdk://Adapters/Criteria">

              <Criteria>

                <FreeformCriteria>

                  <Freeform>

                    <Criteria xmlns="http://Microsoft.EnterpriseManagement.Core.Criteria/">

                      <Expression>

                        <SimpleExpression>

                          <ValueExpressionLeft>

                            <Property>$Context/Property[Type='Problem!System.WorkItem.Problem']/Status$</Property>

                          </ValueExpressionLeft>

                          <Operator>Equal</Operator>

                          <ValueExpressionRight>

                            <Value>$MPElement[Name="Problem!ProblemStatusEnum.Active"]$</Value>

                          </ValueExpressionRight>

                        </SimpleExpression>

                      </Expression>

                    </Criteria>

                  </Freeform>

                </FreeformCriteria>

              </Criteria>

 </QueryCriteria>

 

Presentation

1.       Columns: This is where you specify what all columns you’d like to see in the view. Below is an example of how the column configuration looks like:

<mux:ColumnCollection xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:mux="http://schemas.microsoft.com/SystemCenter/Common/UI/Views/GridView" xmlns:s="clr-namespace:System;assembly=mscorlib"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:data="clr-namespace:Microsoft.EnterpriseManagement.UI.SdkDataAccess.Common;assembly=

Microsoft.EnterpriseManagement.UI.SdkDataAccess">

                                 <mux:Column Name="id" DisplayMemberBinding="{Binding Path=Id}" Width="100" DisplayName="Header_Id" Property="Id" DataType="s:String" />

<mux:Column Name="enabled" Width="100" DisplayMemberBinding="{data:BooleanBinding Path=Enabled}" DisplayName="Header_Enabled" Property="Enabled" DataType="s:Boolean" />

<mux:Column Name="time" DisplayMemberBinding="{datebinding:DateBinding Path= Time}" Width="100" DisplayName="Header_Start_Time" Property=" Time" DataType="s:DateTime" />              

                                 </mux:ColumnCollection>

        Here is the list of attributes that can be used for each column and what they mean:

Name(String): This property defines the name of the column. This property must be set to a non-empty string and has to be unique.

CellTemplate(DataTemplate): This property defines the template used to fill in the cell of the row for an item.

CellTemplateSelector(DataTemplateSelector): This property defines the selection criteria for the value of CellTemplate property.

Converter(IValueConverter): This property defines any converter used when this column is being grouped. The value returned by this converter will become the group title. This property can   be used to define a summary value for grouping.

         DataType(Type): This property determines what type of filtering is used with this column. Note that this type is not used in sorting. The default is string.

DisplayMemberBinding(BindingBase): This property is used as content of the cell for this column in each row. This is optional property. If this property as well as CellTemplate property is not defined, a default binding is created using the value of Property before the column is frozen.

DisplayName(String): This property is used in filter panel and column selection dialog. This represents a display name used for this column. This property is required.

Header(String): This property defines the header that is displayed for this column. This property is optional. The value of DisplayName is set to this property

HeaderTemplate: This property defines the template used on the column header.

HeaderTemplateSelector: This property defines the selection criteria for the HeaderTemplate property.

IsRequired(Boolean): This property defines whether the user can hide this column. The default value is false.

IsVisible(Boolean): This property defines whether the column is initially visible. The user will be able to show the hidden column through the column chooser. The default value is true.

IsRequired(Boolean): This property defines whether the column is always visible. If this property is set true, the user will not be able to hide column. The default value is false.

Property(String): This property is the name of the CLR property associated with this column. This is used with sorting, filtering and grouping. If CellTemplate and DisplayMemberBinding are not defined, this is also used for displaying. This property is required.

Width(double): This property defines the initial width of the column. The default value is ‘Auto’ which is same as Double.NaN.

SortDirection(String):  This property defines the sort order of this column when sorted by this column. The default value is ‘Ascending’. Values applicable Ascending/Descending

GroupDirection(String): This property defines the group order of this column when grouped by this column. The default value is ‘Ascending’. Values applicable Ascending/Descending

SortIndex(int): This property defines the index of this column in sorted columns list. The default value is ‘-1’ which means this column is not in the sorted columns list.

GroupIndex(int): This property defines the index of this column in grouped columns list. The default value is ‘-1’ which means this column is not in the grouped columns list.

 

2.       View Strings: This section is added for localization. Example below:

<ViewString ID="Header_Id">$MPElement[Name="ServiceManager.ProblemManagement.Configuration.View.ActiveProblem.Header_Id"]$</ViewString>     

The ID value here maps to the DisplayName value in the Column section. If the view columns need to be localized, then another management pack element needs to be added for this in StringResources

<StringResources>

      <StringResource ID=" ServiceManager.ProblemManagement.Configuration.View.ActiveProblem.Header_Id"/></StringResources>

and the corresponding DisplayName and description needs to be added in the DisplayStrings section of the LanguagePack

<LanguagePacks>

    <LanguagePack ID="ENU" IsDefault="true">

      <DisplayStrings>

<DisplayString ElementID=" ServiceManager.ProblemManagement.Configuration.View.ActiveProblem.Header_Id ">

          <Name>ID</Name>

          <Description>ID</Description>

        </DisplayString>

</DisplayStrings>

    </LanguagePack>

  </LanguagePacks>

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Is SortIndex working?

    Currently, I have no clue how the view is sorted by default. To prevent manually click the column header and sort everytime the view is loaded. I try to put default sort for my view by using SortIndex. For example:

    <mux:Column Name="time" DisplayMemberBinding="{datebinding:DateBinding Path= Time}" Width="100" DisplayName="Header_Start_Time" Property=" Time" DataType="s:DateTime" SortIndex="0"/>  

    After deployment,I didn't see any changes. Is the configuration correct? Could u provide a example of using SortIndex? Thanks.

  • How can I create view with colored rows based on incident priority?

    And do we need to create xml by hand even in visual studio against xaml file ?

  • Hi,

    Can I create my own viewImplementaion, If yes then how how can I create new implementation and configure in xml(MP) ?

  • connect.microsoft.com/.../sort-options-for-view-doesnt-work

  • Grid view customization

    www.kettic.com/.../gridview_view_definition.shtml

  • Sortindex still doesn't work in Service Manager 2012 R2 UR3. I resubmitted a bug report because the previous link doesn't work anymore. https://connect.microsoft.com/WindowsServer/feedbackdetail/view/982164/pre-sorting-views-doesnt-work