Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functionality to move/change the position of a field/column in a list view. #1144

Closed
1 task done
NewGHUser4321 opened this issue Mar 24, 2023 · 2 comments
Closed
1 task done
Assignees
Labels
area: model 📐 Related to the core SDK models good first contribution Good for newcomers help wanted Extra attention is needed

Comments

@NewGHUser4321
Copy link

Category

  • Feature request

Describe the feature

I'm proposing the PnP Core SDK to have the functionality to move/change the position of a field/column in a list view. This is something similar to what we have in PnPjs.

Describe the solution you'd like

I'm looking for a solution like this or something similar

// Get Documents list with views via title
var myList = await context.Web.Lists.GetByTitleAsync("Documents", p => p.Views);

// Get the view to update
var viewToUpdate = myList.Views.AsRequested().FirstOrDefault(p => p.Title == "All Documents");

// Update the view
await viewToUpdate.MoveFieldAsync(FieldInternalName, index);

Additional context

Currently, since we do not have this functionality in the PnP Core SDK, I have to make Custom SPO Rest Request as in here.

Here is what I had to do to move a field in the default view using the SPO Rest endpoint.

var apiRequest = new ApiRequest(new HttpMethod(WebRequestMethods.Http.Post), ApiRequestType.SPORest, $"{siteUrl}/_api/web/lists('{spList.Id}')/defaultView/viewfields/moveviewfieldto", $"{{\"field\":\"{FieldInternalName}\",\"index\":3}}");

await spList.ExecuteRequestAsync(apiRequest);
@jansenbe
Copy link
Contributor

@NewGHUser4321 : that's nice addition to add, thanks for sharing the API call you've used, this will make it easier to include the feature!

@jansenbe jansenbe added good first contribution Good for newcomers help wanted Extra attention is needed area: model 📐 Related to the core SDK models labels Mar 24, 2023
@jansenbe jansenbe self-assigned this Apr 21, 2023
@jansenbe
Copy link
Contributor

@NewGHUser4321 : I've implemented this + also added support to add/remove a field from an existing view. Docs are processing now and will appear in https://pnp.github.io/pnpcore/using-the-sdk/lists-views.html.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: model 📐 Related to the core SDK models good first contribution Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants