Export (0) Print
Expand All

Views.UpdateViewHtml Method

Windows SharePoint Services 3
Updates the specified view with the supplied properties and values, including the display properties of Introduction to Collaborative Application Markup Language (CAML) and HTML.

Web Service: ViewsWeb Reference: http://<Site>/_vti_bin/Views.asmx

[SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/UpdateViewHtml", RequestNamespace="http://schemas.microsoft.com/sharepoint/soap/", ResponseNamespace="http://schemas.microsoft.com/sharepoint/soap/", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)] 
public XmlNode UpdateViewHtml (
	string listName,
	string viewName,
	XmlNode viewProperties,
	XmlNode toolbar,
	XmlNode viewHeader,
	XmlNode viewBody,
	XmlNode viewFooter,
	XmlNode viewEmpty,
	XmlNode rowLimitExceeded,
	XmlNode query,
	XmlNode viewFields,
	XmlNode aggregations,
	XmlNode formats,
	XmlNode rowLimit
)

Parameters

listName

A string that contains the internal name of the list.

viewName

A string that contains the GUID for the view.

viewProperties

An XML fragment that contains all view-level properties as attributes, such as Editor, Hidden, ReadOnly, and Title.

toolbar

A Toolbar element that sets the HTML used to render the toolbar in a view and that can be assigned to a System.Xml.XmlNode object, as in the following example:

<Toolbar Type="Standard">
  <IfEqual>
    <Expr1>
      <GetVar Name="SearchString" />
    </Expr1>
    <Expr2 />
    <Then>
    ...
</Toolbar>
viewHeader

A ViewHeader element that sets the HTML used to render the header of a view and that can be assigned to a System.Xml.XmlNode object, as in the following example:

<ViewHeader>
  <HTML>
    <![CDATA[ <TABLE width="100%" cellspacing=0 cellpadding=0 border=0> ]]>
  </HTML>
  ...
</ViewHeader>
viewBody

A ViewBody element that sets the HTML used to render the body of a view and that can be assigned to a System.Xml.XmlNode object, as in the following example:

<ViewBody>
  <HTML>
    <![CDATA[ <TR>]]>
  </HTML>
  <Fields>
    <HTML>
      <![CDATA[ <TD Class=" ]]> 
    </HTML>
    ...
</ViewBody>
viewFooter

A ViewFooter element that sets the HTML used to render the footer of a view and that can be assigned to a System.Xml.XmlNode object, as in the following example:

<ViewFooter>
  <HTML>
    <![CDATA[ </TABLE> ]]>
  </HTML>
  <IfEqual>
  ...
</ViewFooter>
viewEmpty

A ViewEmpty element that contains the HTML used to render the page if the query returns no items and that can be assigned to a System.Xml.XmlNode object, as in the following example:

<ViewEmpty>
  <HTML>
    <![CDATA[ <TABLE width="100%" cellspacing=0 cellpadding=0 border=0><tr><td> ]]>
  </HTML>
  ...
</ViewEmpty>
rowLimitExceeded

A RowLimitExceeded element that specifies alternate rendering for when the specified row limit is exceeded and that can be assigned to a System.Xml.XmlNode object, as in the following example:

<RowLimitExceeded>
  <HTML><![CDATA[ <table class="ms-summarycustombody" cellpadding=0 cellspacing=0 border=0 rules=rows>
  ...
    </td></tr></table> ]]>
  </HTML>
</RowLimitExceeded>
query

A Query element containing the query that determines which records are returned and in what order, and that can be assigned to a System.Xml.XmlNode object. The following example performs a query for cases in which the ID field is less than 3, and displays items in the order of their titles:

<Query>
  <Where>
    <Lt>
      <FieldRef Name="ID" />
      <Value Type="Counter">3</Value>
    </Lt>
  </Where>
  <OrderBy>
    <FieldRef Name="Title" />
  </OrderBy>
</Query>
viewFields

A ViewFields element that specifies which fields to return in the query and in what order, and that can be assigned to a System.Xml.XmlNode object, as in the following example:

<ViewFields>
  <FieldRef Name="ID" />
  <FieldRef Name="Title" />
</ViewFields>
aggregations

An Aggregations element that specifies the fields to aggregate and that can be assigned to a System.Xml.XmlNode object, as in the following example:

<Aggregations Value="On">
  <FieldRef Name="Title" Type="Count">
  <FieldRef Name="Number" Type="Sum">
</Aggregations>
formats

A Formats element that defines the grid formatting for columns and that can be assigned to a System.Xml.XmlNode object, as in the following example:

<Formats>
  <FormatDef Type="RowHeight" Value="67" />
  <Format Name="Attachments">
    <FormatDef Type="ColWidth" Value="75" />
  </Format>
  <Format Name="LinkTitle">
    <FormatDef Type="WrapText" Value="1" />
    <FormatDef Type="ColWidth" Value="236" />
  </Format>
  ...
</Formats>
rowLimit

A RowLimit element that specifies the number of items, or rows, to display on a page before paging begins and that can be assigned to a System.Xml.XmlNode object. The fragment can include the Paged attribute to specify that the view return list items in pages. The following example sets a limit of 100 items per page:

<RowLimit Paged="True">100</RowLimit>

Return Value

A CAML fragment in the following form that contains the view schema and that can be assigned to a System.Xml.XmlNode object.
<View Name="{54992C89-4F9F-4B2E-8E5A-F55C1C70831B}" Type="HTML" DisplayName="MyView" Url="Lists/TestCustList/MyView.aspx" BaseViewID="1" xmlns="http://schemas.microsoft.com/sharepoint/soap/">
  <ViewFields>
    <FieldRef Name="Attachments" />
    <FieldRef Name="LinkTitle" />
    <FieldRef Name="ID" />
    <FieldRef Name="Created" />
  </ViewFields>
  <Query>
  ...
  </Query>
  <ViewEmpty>
  ...
  </ViewEmpty>
  <GroupByHeader>
  ...
  </GroupByHeader>
  <GroupByFooter>
  ...
  </GroupByFooter>
  <ViewHeader>
  ...
  </ViewHeader>
  <ViewBody>
  ...
  </ViewBody>
  <ViewFooter>
  ...
  </ViewFooter>
  <PagedRowset>
  ...
  </PagedRowset>
  <PagedRecurrenceRowset>
  ...
  </PagedRecurrenceRowset>
  <RowLimit Paged="TRUE">100</RowLimit>
  <ViewBidiHeader>
  ...
  </ViewBidiHeader>
  <Toolbar Type="Standard">
  ...
  </Toolbar>
</View>

To modify only the query and field definitions in a view, use the UpdateView method.

The following code example modifies the View Footer region in a view, adding text and a hyperlink to the Announcements list in the current site.

Web_Reference_Folder.Views viewService = new Web_Reference_Folder.Views();
viewService.Credentials= System.Net.CredentialCache.DefaultCredentials;

XmlDocument xmlDoc = new System.Xml.XmlDocument();

string strViewEmpty = "<HTML><![CDATA[" + 
   "<TABLE width=\"100%\" cellspacing=0 cellpadding=0 border=0>" + 
   "<tr><td>]]></HTML><HTML><![CDATA[" +
   "<TABLE ID=onetidDoclibViewTbl0 width=\"100%\" Summary=\"]]>" + 
   "</HTML><ListProperty Select=\"Title\" HTMLEncode=\"TRUE\" />" +
   "<HTML><![CDATA[\" ]]></HTML>" + 
   "<HTML><![CDATA[border=0 rules=rows><TR>]]></HTML>" +
   "<Fields><Switch><Expr>" + 
   "<Property Select=\"Name\" /></Expr><Case Value=\"Attachments\">" + 
   "<HTML><![CDATA[<TH class=\"ms-vh-icon\">]]></HTML>" +
   "<Field /><HTML><![CDATA[</TH>]]></HTML>" + 
   "</Case><Default><Switch><Expr>" + 
   "<Property Select=\"HeaderImage\" /></Expr><Case Value=\"\">" + 
   "<HTML><![CDATA[<TH class=\"ms-vh\">]]></HTML>" + 
   "<Field /><HTML><![CDATA[</TH>]]></HTML>" + 
   "</Case><Default><HTML><![CDATA[" + 
   "<TH class=\"ms-vh-icon\">]]></HTML><Field />" + 
   "<HTML><![CDATA[</TH>]]></HTML>" +
   "</Default></Switch></Default></Switch></Fields>" + 
   "<HTML><![CDATA[</TR>]]></HTML><HTML><![CDATA[</TABLE>]]></HTML>" + 
   "<HTML><![CDATA[</td></tr>]]></HTML>" +
   "<HTML><![CDATA[<tr><td>]]></HTML>" + 
   "<HTML><![CDATA[<TABLE ]]></HTML>" + 
   "<HTML><![CDATA[ width=100% ]]></HTML>" + 
   "<HTML><![CDATA[ border=0 rules=rows><TR>]]></HTML>" +
   "<IfEqual><Expr1>" + 
   "<GetVar Name=\"SearchString\" /></Expr1><Expr2 /><Then><HTML>" + 
   "<![CDATA[<TD Class=\"ms-vb\"> ]]></HTML>" +
   "<HTML>All work items in the \"</HTML>" +
   "<ListProperty Select=\"Title\" HTMLEncode=\"TRUE\" />" +
   "<HTML>\" list have been completed. See </HTML>" + 
   "<HTML><![CDATA[<A HREF=\"]]></HTML>" +
   "<HttpVDir URLEncode=\"TRUE\"/>" +
   "<HTML><![CDATA[/Lists/Announcements/AllItems.aspx\">]]></HTML>" + 
   "<HTML>Announcements</HTML><HTML><![CDATA[</A>]]></HTML>" +
   "<HTML> for details.</HTML>" + 
   "<HTML><![CDATA[</TD>]]></HTML></Then><Else>" +
   "<HTML><![CDATA[<TD class=\"ms-vb\"><B>]]></HTML>" + 
   "<HTML>No records were found matching your query.</HTML>" +
   "<HTML><![CDATA[</B></TD>]]></HTML>" +
   "</Else></IfEqual><HTML><![CDATA[</TR></TABLE>]]></HTML>" +
   "<HTML><![CDATA[</td></tr></TABLE>]]></HTML>";

XmlNode ndViewEmpty = xmlDoc.CreateNode(XmlNodeType.Element,"ViewEmpty","");

ndViewEmpty.InnerXml = strViewEmpty;

viewService.UpdateViewHtml("List_Name", "9781bd25-1f68-481f-81d3-1e4f3f9216dd", null, null, null, null, null, ndViewEmpty, null, null, null, null, null, null);

Community Additions

ADD
Show:
© 2014 Microsoft