2011-03-07 31 views
2

我已經從我的列表中加載了我的自動完成組合框腳本:http://jqueryui.com/demos/autocomplete/#combobox ,它出現在我的列表中。使用自動完成來過濾SharePoint中的jQuery列表中的列表

在它下面,我有使用作品就好列表:

  • 功能processResult(XDATA,狀態){$ (xData.responseXML).find( 「目錄」),每個(函數(){ $(「#data」)。append(+ $(this).attr(「Title」)+); }); }
  • 感謝揚Tielens Bloggings: http://weblogs.asp.net/jan/archive/2009/04/09/calling-the-sharepoint-web-services-with-jquery.aspx

    我如何獲取列表一旦選擇一些實際過濾器?我假設它在$(this).attr()中,但似乎沒有任何工作。

    道歉提前爲DAY1新手問題。

    感謝

    +2

    看一看SPServices與使用jQuery/JavaScript的Web服務的SharePoint通信:HTTP:// spservices。 codeplex.com/ – Dribbel 2011-03-07 20:25:22

    +0

    你能闡述一下你打算如何使用它?你正在編寫一個自定義的Web部件?你使用的是adataview的web部件,列表視圖等。 – 2011-03-08 02:09:09

    回答

    3

    使用SPServices和自動完成使用select選項:

    <link href="../css/jquery-ui.css" rel="stylesheet" type="text/css"/> 
    <script type="text/javascript" src="../js/jquery.min.js"></script> 
    <script type="text/javascript" src="../js/jquery-ui.js"></script> 
    <script type="text/javascript" src="../js/jquery.SPServices-0.5.8.js"></script> 
    
    <script type="text/javascript"> 
    $(document).ready (function() { 
        $().SPServices({ 
         operation: "GetListItems", 
         async: true, 
         listName: "Resources", 
         CAMLViewFields: "<ViewFields>" + 
          "<FieldRef Name='Title' />" + 
          "<FieldRef Name='resource_link' />" + 
          "<FieldRef Name='image_url' />" + 
          "</ViewFields>", 
         completefunc: AttachAutoComplete 
        }); 
    
        function AttachAutoComplete(xmlResponse) { 
         var domElementArray = $("[nodeName=z:row]", xmlResponse.responseXML); 
    
         var dataMap = domElementArray.map(function() { 
          return { 
           value: $(this).attr('ows_Title'), 
           url: $(this).attr('ows_resource_link'), 
           image_url: $(this).attr('ows_image_url') 
          }; 
         }); 
    
         var data = dataMap.get(); 
    
         $("input#inputAutoComplete").autocomplete({ 
          source: data, 
          formatItem: function(row){ 
           if(row){ 
            return "<table><tr><td><img src=\"" + row.image_url + "\" border=\"0\" /></td><td>"+ row.value + " 55</td></tr></table>"; 
           } 
          }, 
          select: function(e, ui){ 
           window.open(ui.item['url']); 
          } 
         }); 
        } 
    </script> 
    
    +0

    這太棒了! 如果我添加:$(「#tasksUL」)。empty(); 當我再次選擇自動完成時,下拉列表將會刷新。 – MD18358 2011-03-09 12:16:25

    +0

    .html(「」)也可以...:o)但是我會堅持你擁有的。 – trgraglia 2011-03-09 12:43:47

    +0

    由於您是堆棧溢出新手......您應該接受答案。這有助於表明他們得到了回答,並幫助您和其他人獲得應有的聲望點,這也使用戶能夠在網站上擁有更多的選擇和資源。玩的開心。 – trgraglia 2011-03-09 12:45:23

    1

    您可以觸發,即使你使用的是標準輸入的的onkeyup。它看起來是這樣的:

    <input type="text" name="search" id="txtSearch" onkeyup="searchOpen()" /> 
    
    相關問題