1

リストにアクセスし、CAMLを適用できるSharePointWebパーツを作成するにはどうすればよいですか。

CAMLは、「Position」>0のフィールドを持つリターンのみのリストアイテムを表示するために必要です。

また、xsltを適用するWebパーツも必要です。

4

2 に答える 2

3

You need to add the Content Query Web Part to your page (note: requires MOSS not free WSS). This allows you to query your data and apply an XSL transform to it.

The web part allows you to query a particular site collection, web or list. You can then set parameters to return data of a certain type and apply filters, sorting and grouping. You can also choose how you wish the data to be displayed which appears to the end user as a dropdown list of options. Each of these options is powered by an XSL transform.

This blog post by Heather Solomon is one of the best resources to help you get started with how to create your own transform and configure the CQWP. It also explains how to ensure all the fields you need are passed through to the XSLT (by default this only happens for a small subset).

Update:

To only return list items where the field "Position" > 0, it is simplest to do this within XSLT as well. You must have added the Position field to CommonViewFields so that it gets passed through to the XSLT. Then in your custom item style (in ItemStyle.xsl if you follow Heather's post), add the following:

<xsl:if test="@Position &gt; 0">
  <!-- Display desired row output -->
</xsl:if>

This implicitly ignores when "Position" <= 0.

于 2009-06-17T14:36:29.387 に答える
1

可能な場合は、コンテンツ クエリ Web パーツ (CQWP) を使用するという Alex の意見に同意します。

ただし、コードに入りたい場合は、次のようなことができます。大まかな部分は、それを XML に変換することですが、XML の非カスタム (醜い) 形式に変換する簡単な方法があるかもしれません。

SPList list = web.Lists["My List Name"];
SPView view = list.Views["My View Name"];  // This view would define Postion > 0
SPQuery query = new SPQuery(view);
SPListItemCollection items = list.GetItems(query);

// Iterate through results and generate XML

既存のビューを使用したくない場合は、手動で SPQuery オブジェクトを設定する必要があります。その ViewFields、Query、および RowLimit を最小限に設定します。これには、 CAML クエリ ツールを使用できます。

于 2009-06-17T22:24:42.197 に答える