2011-09-15 39 views
0

我已被放入SharePoint項目中,並且我對改變現有Web部件的經驗相對較少。MOSS 2007:將篩選器添加到ListView Web部件

我的第一個任務是在列表視圖中爲三列中的兩列添加一個過濾器。 My Lead Dev建議嘗試添加一個jQuery組合框過濾器,另一個開發人員建議擴展Web部件並覆蓋一些功能。

我認爲一個好的選擇是更改列表視圖標題的上下文菜單,這樣,而不是「顯示篩選器選擇」提出一個標準的dropdownlist,只響應第一個字母,它會有一個jQuery組合框。也許如果企業要求它,請更改該選項的措辭。

我對你的問題是,這將是一個很好的路徑嗎?另外,還有哪些資源除了在書籍和博客上播放外,還有什麼可以引導新手去做這件事?

謝謝。

回答

1

怎麼是這樣的:

<script src="http://www.google.com/jsapi"></script> 

    <script> 
     google.load("jquery", "1.2.6"); 
     google.setOnLoadCallback(function() { 

      $(document).ready(function() 
      { 
       jQuery.extend(jQuery.expr[':'], { 
       containsIgnoreCase: "(a.textContent||a.innerText||jQuery(a).text()||'').toLowerCase().indexOf((m[3]||'').toLowerCase())>=0" 
    }); 

    $("table.ms-listviewtable tr.ms-viewheadertr").each(function() 
    { 
     if($("td.ms-vh-group", this).size() > 0) 
     { 
      return; 
     } 
     var tdset = ""; 
     var colIndex = 0; 
     $(this).children("th,td").each(function() 
     { 
      if($(this).hasClass("ms-vh-icon")) 
      { 
       // attachment 
       tdset += "<td></td>"; 
      } 
      else 
      { 
       // filterable 
       tdset += "<td><input type='text' class='vossers-filterfield' filtercolindex='" + colIndex + "' /></td>"; 
      } 
      colIndex++; 
     }); 
     var tr = "<tr class='vossers-filterrow'>" + tdset + "</tr>"; 
     $(tr).insertAfter(this); 
    }); 

     $("input.vossers-filterfield") 
      .css("border", "1px solid #7f9db9") 
      .css("width", "100%") 
      .css("margin", "2px") 
      .css("padding", "2px") 
      .keyup(function() 
     { 
      var inputClosure = this; 
      if(window.VossersFilterTimeoutHandle) 
      { 
       clearTimeout(window.VossersFilterTimeoutHandle); 
      } 
      window.VossersFilterTimeoutHandle = setTimeout(function() 
      { 
      var filterValues = new Array(); 
      $("input.vossers-filterfield", $(inputClosure).parents("tr:first")).each(function() 
      { 
       if($(this).val() != "") 
       { 
        filterValues[$(this).attr("filtercolindex")] = $(this).val(); 
       } 
      }); 
      $(inputClosure).parents("tr.vossers-filterrow").nextAll("tr").each(function() 
      { 
       var mismatch = false; 
       $(this).children("td").each(function(colIndex) 
       { 
        if(mismatch) return; 
        if(filterValues[colIndex]) 
        { 
         var val = filterValues[colIndex]; 
         // replace double quote character with 2 instances of itself 
         val = val.replace(/"/g, String.fromCharCode(34) + String.fromCharCode(34)); 
         if($(this).is(":not(:containsIgnoreCase('" + val + "'))")) 
         { 
          mismatch = true; 
         } 
        } 
       }); 
       if(mismatch) 
       { 
        $(this).hide(); 
       } 
       else 
       { 
        $(this).show(); 
       } 
       }); 
      }, 250); 
     }); 
    }); 
}); 

它需要通過一個內容編輯器Web部件添加到頁面。

相關問題