Sharepoint MOSS 2007:向ListView web部件添加筛选器

Sharepoint MOSS 2007:向ListView web部件添加筛选器,sharepoint,sharepoint-2007,web-parts,moss,Sharepoint,Sharepoint 2007,Web Parts,Moss,我参加了一个sharepoint 2007项目,对修改现有Web部件的经验相对较少 我的第一个任务是为列表视图中三列中的两列添加筛选器。我的主要开发人员建议尝试添加jquery组合框过滤器,另一个开发人员建议扩展web部件并覆盖某些功能 我认为一个很好的选择是更改列表视图标题的上下文菜单,这样就不用“显示过滤器选项”来显示只响应第一个字母的标准dropdownlist,而是有一个jquery组合框。如果业务部门要求,也许可以更改该选项的措辞 我想问你的问题是,什么是解决这个问题的好方法?此外,除

我参加了一个sharepoint 2007项目,对修改现有Web部件的经验相对较少

我的第一个任务是为列表视图中三列中的两列添加筛选器。我的主要开发人员建议尝试添加jquery组合框过滤器,另一个开发人员建议扩展web部件并覆盖某些功能

我认为一个很好的选择是更改列表视图标题的上下文菜单,这样就不用“显示过滤器选项”来显示只响应第一个字母的标准dropdownlist,而是有一个jquery组合框。如果业务部门要求,也许可以更改该选项的措辞

我想问你的问题是,什么是解决这个问题的好方法?此外,除了阅读书籍和博客,还有哪些资源可以指导sp新手这样做


谢谢。

像这样的东西怎么样:

    <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);
        });
    });
});

load(“jquery”,“1.2.6”);
google.setOnLoadCallback(函数(){
$(文档).ready(函数()
{ 
extend(jQuery.expr[':']{
containsIgnoreCase:“(a.textContent | | a.innerText | | | jQuery(a.text()| |“”).toLowerCase().indexOf((m[3]| |“”))>=0”
});
$(“table.ms-listviewtable tr.ms-viewheadertr”)。每个(函数()
{
如果($(“td.ms vh组”,this).size()>0)
{
返回;
}
var tdset=“”;
var-colIndex=0;
$(this).children(“th,td”).each(function()
{
if($(此).hasClass(“ms vh图标”))
{
//附件:
tdset+=“”;
}
其他的
{
//可过滤
tdset+=“”;
}
colIndex++;
});
var tr=“”+tdset+”;
$(tr).插入后面(this);
}); 
$(“input.vossers filterfield”)
.css(“边框”,“1px实体#7f9db9”)
.css(“宽度”、“100%”)
.css(“保证金”、“2px”)
.css(“填充”、“2px”)
.keyup(函数()
{ 
var-inputClosure=this;
if(window.VossersFilterTimeoutHandle)
{
clearTimeout(window.VossersFilterTimeoutHandle);
}
window.VossersFilterTimeoutHandle=setTimeout(函数()
{
var filterValues=新数组();
$(“input.vossers filterfield”,$(inputClosure).parents(“tr:first”).each(function()
{ 
if($(this.val()!=“”)
{
FilterValue[$(this.attr(“filtercolindex”)]=$(this.val();
}
}); 
$(inputClosure).parents(“tr.vossers-filterrow”).nextAll(“tr”).each(function()
{
var不匹配=假;
$(this).children(“td”).each(函数(colIndex)
{
如果(不匹配)返回;
if(filterValues[colIndex])
{
var val=过滤值[colIndex];
//将双引号字符替换为其自身的两个实例
val=val.replace(/“/g,String.fromCharCode(34)+String.fromCharCode(34));
if($(this).is(:not(:containsIgnoreCase(“+val+”))))
{
不匹配=真;
} 
}
});
如果(不匹配)
{
$(this.hide();
}
其他的
{
$(this.show();
} 
}); 
}, 250);
});
});
});

它需要通过内容编辑器web部件添加到页面中