You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unable to set ColumnWidth via ListViewXml for List ViewΒ #1596
When setting column width of a List View, setting ListViewXml of a view doesn't seem to persist, but instead the list view is reset to default. By "reset" I mean that if I have added field to the view earlier, it is also removed, so the View resets to default fields too. This works when doing via PnP JS, but not when using PnP Core.
Steps to reproduce
// create list
var list = await destinationSiteContext.Web.Lists.AddAsync(listName, ListTemplateType.DocumentLibrary);
var defaultView = list.Views.First();
// get existing ListViewXml, add ColumnWidth definition for one field
var defaultViewXml = defaultView.ListViewXml
.Replace(
"</View>",
"<ColumnWidth><FieldRef Name=\"Modified\" width=\"370\" /></ColumnWidth></View>"
);
// save changes to view
defaultView.ListViewXml = defaultViewXml;
await defaultView.UpdateAsync();
Expected behavior
ListViewXml would contain the ColumnWidth definition and view in UI would also have wide Modified column.
Activity
jansenbe commentedon Jan 30, 2025
@jpalo : In PnPJS the SetViewXml methodf is used to set the view whereas PnP Core SDK sets the ListViewXml property. Check the internal code it seems that SetViewXml is setting some internal property next to setting the ListViewXml property, so most likely this can be fixed by adding a method to PnP Core SDK for this in https://github.com/pnp/pnpcore/blob/dev/src/sdk/PnP.Core/Model/SharePoint/Core/Internal/View.cs and https://github.com/pnp/pnpcore/blob/dev/src/sdk/PnP.Core/Model/SharePoint/Core/Public/IView.cs.
Would be great if you can do that, alternatively you can unblock yourselves by making the API call using our built in custom API calling feature: https://pnp.github.io/pnpcore/using-the-sdk/basics-customapirequests.html#making-a-custom-spo-rest-request
Guflly commentedon Aug 5, 2026
I would like to work on this.
Adam-it commentedon Aug 5, 2026
Perfect π All yours
Fix pnp#1596: add SetViewXml API for list views