Skip to main content
Noted the same behaviour for built in List App.
Source Link
Robert Lindgren
  • 24.5k
  • 12
  • 53
  • 79

Search in XSLT List View Webpartview on publishing page layout

UPDATE after trying the OOTB list app:

I have a strange issue with placing a custom XSLT List View Webpartlist view web part on a publishing page layout.

My code:Note that this it true both for custom XSLT webpart and for the "App" for the list.

protected override void CreateChildControls()
        {
            using (var site = new SPSite(SPContext.Current.Site.ID))
            {
                using (var projectWeb = site.OpenWeb(Constants.Paths.ProjectWeb))
                {
                    var publishingWeb = PublishingWeb.GetPublishingWeb(projectWeb);

                    var pagesLibrary = publishingWeb.PagesList;
                    var pagesListGuid = pagesLibrary.ID.ToString("B").ToUpper();

                    SPView view;
                    try
                    {
                        view = pagesLibrary.Views["Projekt"];
                    }catch
                    {
                        view = pagesLibrary.DefaultView;
                    }

                    listViewWebPart = new XsltListViewWebPart();
                    listViewWebPart.ListName = pagesListGuid;
                    listViewWebPart.ViewGuid = view.ID.ToString();
                    listViewWebPart.ViewId = int.Parse(view.BaseViewID);
                    listViewWebPart.XmlDefinition = view.GetViewXml();
                    listViewWebPart.JSLink = "/_layouts/15/myfolder/js/projectListTemplates.js";
                    listViewWebPart.Title = "Projekt";
                    listViewWebPart.DisableViewSelectorMenu = true;
                    listViewWebPart.InplaceSearchEnabled = true;
                    listViewWebPart.AsyncRefresh = true; // Have tried without this one
                    listViewWebPart.InitialAsyncDataFetch = true; // Have tried without this one
                    listViewWebPart.ClientRender = true;
                    listViewWebPart.ChromeType = PartChromeType.None;

                    Controls.Add(listViewWebPart);
                }
            }
        }

Search in XSLT List View Webpart

I have a strange issue with a custom XSLT List View Webpart.

My code:

protected override void CreateChildControls()
        {
            using (var site = new SPSite(SPContext.Current.Site.ID))
            {
                using (var projectWeb = site.OpenWeb(Constants.Paths.ProjectWeb))
                {
                    var publishingWeb = PublishingWeb.GetPublishingWeb(projectWeb);

                    var pagesLibrary = publishingWeb.PagesList;
                    var pagesListGuid = pagesLibrary.ID.ToString("B").ToUpper();

                    SPView view;
                    try
                    {
                        view = pagesLibrary.Views["Projekt"];
                    }catch
                    {
                        view = pagesLibrary.DefaultView;
                    }

                    listViewWebPart = new XsltListViewWebPart();
                    listViewWebPart.ListName = pagesListGuid;
                    listViewWebPart.ViewGuid = view.ID.ToString();
                    listViewWebPart.ViewId = int.Parse(view.BaseViewID);
                    listViewWebPart.XmlDefinition = view.GetViewXml();
                    listViewWebPart.JSLink = "/_layouts/15/myfolder/js/projectListTemplates.js";
                    listViewWebPart.Title = "Projekt";
                    listViewWebPart.DisableViewSelectorMenu = true;
                    listViewWebPart.InplaceSearchEnabled = true;
                    listViewWebPart.AsyncRefresh = true; // Have tried without this one
                    listViewWebPart.InitialAsyncDataFetch = true; // Have tried without this one
                    listViewWebPart.ClientRender = true;
                    listViewWebPart.ChromeType = PartChromeType.None;

                    Controls.Add(listViewWebPart);
                }
            }
        }

Search in List view on publishing page layout

UPDATE after trying the OOTB list app:

I have a strange issue with placing a list view web part on a publishing page layout.

Note that this it true both for custom XSLT webpart and for the "App" for the list.

Source Link
Robert Lindgren
  • 24.5k
  • 12
  • 53
  • 79

Search in XSLT List View Webpart

I have a strange issue with a custom XSLT List View Webpart.

The searchbox is displaying, but when I search it does not load any results (the spinner never stops spinning).

The javascript console spits out:

inplview is undefined

so I tried referencing inplview.js. This makes the error message disappear, but still no luck with loading search results. Filtering and sorting works great though.

My code:

protected override void CreateChildControls()
        {
            using (var site = new SPSite(SPContext.Current.Site.ID))
            {
                using (var projectWeb = site.OpenWeb(Constants.Paths.ProjectWeb))
                {
                    var publishingWeb = PublishingWeb.GetPublishingWeb(projectWeb);

                    var pagesLibrary = publishingWeb.PagesList;
                    var pagesListGuid = pagesLibrary.ID.ToString("B").ToUpper();

                    SPView view;
                    try
                    {
                        view = pagesLibrary.Views["Projekt"];
                    }catch
                    {
                        view = pagesLibrary.DefaultView;
                    }

                    listViewWebPart = new XsltListViewWebPart();
                    listViewWebPart.ListName = pagesListGuid;
                    listViewWebPart.ViewGuid = view.ID.ToString();
                    listViewWebPart.ViewId = int.Parse(view.BaseViewID);
                    listViewWebPart.XmlDefinition = view.GetViewXml();
                    listViewWebPart.JSLink = "/_layouts/15/myfolder/js/projectListTemplates.js";
                    listViewWebPart.Title = "Projekt";
                    listViewWebPart.DisableViewSelectorMenu = true;
                    listViewWebPart.InplaceSearchEnabled = true;
                    listViewWebPart.AsyncRefresh = true; // Have tried without this one
                    listViewWebPart.InitialAsyncDataFetch = true; // Have tried without this one
                    listViewWebPart.ClientRender = true;
                    listViewWebPart.ChromeType = PartChromeType.None;

                    Controls.Add(listViewWebPart);
                }
            }
        }