1
Vote

发现两个问题,已处理。视图加排序导出功能bug;在自定义页面上使用bug

description

//修改可应用到 SmartQueryWebPart.cs ListQueryWebPart.cs
//以下ListQueryWebPart.cs 为例,文件路径:CodeArt.SharePoint.SmartQuery/ListQueryWebPart.cs


//添加using
using ASPWebPart = System.Web.UI.WebControls.WebParts;


//第一个修改,99行
private SPList _list;
    protected internal virtual SPList List
    {
        //enhancement: 在SitePage/Page库中新加页面,加list view webpart时,搜索功能字段是页面库的,不是目标list,
        //这里通过查找页面上的 XsltListViewWebPart ,找到目标list,解决这个问题;
        //By michaexiang@outlook.com  2014/8/28
        get
        {
            if (_list == null)
            {
                ASPWebPart.WebPartCollection webParts = ASPWebPart.WebPartManager.GetCurrentWebPartManager (this.Page).WebParts;
                foreach (ASPWebPart.WebPart wp in webParts)
                {
                    if (wp is XsltListViewWebPart)
                    {
                        XsltListViewWebPart xsltListViewWebPart = wp as XsltListViewWebPart;
                        if (xsltListViewWebPart != null)
                        {
                            Guid listID = xsltListViewWebPart.ListId;
                            SPWeb currentWeb = SPContext.Current.Web;
                            _list = currentWeb.Lists[listID];
                            break;
                        }
                    }
                }
                if (_list == null)
                {
                    _list = SPContext.Current.List;
                    if (_list == null)
                    {
                        throw new Exception("can't find current list");
                    }
                }
            }
            return _list;
        }
    }
//第二个修改,protected virtual void ApplyExport() 方法中;
        if (queryView != null)
        {
            //enhancement:问题: 在list view 视图中有设置排序和过滤,把queryView.Query直MergeWhere进去,导出功能报错。
            // queryView.Query对order by 与 where 分开处理,解决报错问题,导出结果也包含原来的排序,过滤;
    //By michaexiang@outlook.com  2014/8/28
            string primaryWhere = queryView.Query ;
            int orderByIndex = primaryWhere.IndexOf("</OrderBy>");

            if (orderByIndex > -1)
            {
                string orderStr = primaryWhere.Substring(0, orderByIndex + 10);
                string whereStr = primaryWhere.Substring(orderByIndex + 10);
                where = ListWebPartQueryManager.MergeWhere(where, whereStr);
                where = where + orderStr;
            }
            else
            {
                where = ListWebPartQueryManager.MergeWhere(where, primaryWhere);
            }
        }
有问题,请回复。

comments