0

WebServicesを使用してSharePointリストのすべてのリストアイテムをWindows7ガジェットに取得しようとしていますが、どうすればよいかわかりません。

説明なしでこのコードをグーグルで見つけたので、このコードを使用してリストのデータを取得し、Windowsガジェットに表示する方法がわかりません。

誰かが私を正しい方向に導いてくれますか?

Gadget.xml

    <?xml version="1.0" encoding="utf-8" ?>
<gadget>
  <name>HelloGadget</name>
  <version>1.0.0.0</version>
  <description>Hello World Gadget.</description>
  <hosts>
    <host name="sidebar">
      <base type="HTML" apiVersion="1.0.0" src="first.html" />
      <permissions>Full</permissions>
      <platform minPlatformVersion="1.0" />
    </host>
  </hosts>
</gadget>

first.html

    <html>
<script>
//----------------- resizes the gadget display surface
function DoInit() {
    document.body.style.width = 90;
    document.body.style.height= 55;
    document.body.style.margin=0;
}

    $(document).ready(function() 
{
    var soapEnv =
        "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> 
            <soapenv:Body> 
                 <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> 
                    <listName>ListName</listName> 
                    <viewFields> 
                        <ViewFields> 
                           <FieldRef Name='Title' /> 
                       </ViewFields> 
                    </viewFields> 
                </GetListItems> 
            </soapenv:Body> 
        </soapenv:Envelope>";

    $.ajax({
        url: "http://my_site/_vti_bin/lists.asmx",
        type: "POST",
        dataType: "xml",
        data: soapEnv,
        complete: processResult,
        contentType: "text/xml; charset="utf-8""
    });
});

function processResult(xData, status) {
    $(xData.responseXML).find("z\:row").each(function() {
        alert($(this).attr("ows_Title"));
    });
}

</script>
<body onload="DoInit();">
<table border="5"><tr><td><center><i>Hello World!</i></center></td></tr></table>
<div id = "clickit"> <button type="button" onclick="" >Click Me!</button> </div>
</body>
</html>

乾杯

4

1 に答える 1

0

私たちは皆SQLに精通しています。SPSQLと呼ばれる新しいjQueryライブラリがあります。SQL構文を使用してSharePointにクエリを実行できるため、これは非常に便利です。適切なライブラリを追加するだけで、すぐに使用できます。以下の例とこちらの記事をご覧ください。

アイテムを入手するには、次の手順を実行します。

var result = SPSql.parseSQL('SELECT MyList.Field FROM MyList WHERE MyList.ID > 10 ORDER BY  MyList.ID DESC');

これで、すべての結果行を処理できるようになりました。

for (var row = 0; row < result.length; row++) {
   for (var column in result[row])
      alert( column + ": " + result[row][column] );
 }
于 2012-05-18T08:17:16.300 に答える