sp-dev-fx-webparts/samples/sharepoint-crud/README.md

127 lines
6.3 KiB
Markdown
Raw Normal View History

---
page_type: sample
products:
- office-sp
languages:
- javascript
- typescript
extensions:
contentType: samples
technologies:
- SharePoint Framework
platforms:
- JQuery
- Knockout
- React
createdDate: 1/1/2016 12:00:00 AM
---
2016-09-16 00:33:47 -04:00
# SharePoint CRUD operations
## Summary
Sample Web Parts illustrating performing SharePoint CRUD operations in React, Angular, JavaScript without any framework and using the [@pnp/sp library](https://github.com/pnp/pnpjs).
2016-09-16 00:33:47 -04:00
![Sample To do SharePoint Framework Client-Side Web Part built using Angular and ngOfficeUIFabric](./assets/preview.png)
2021-09-26 10:54:22 -04:00
## Compatibility
| :warning: Important |
|:---------------------------|
| Every SPFx version is only compatible with specific version(s) of Node.js. In order to be able to build this sample, please ensure that the version of Node on your workstation matches one of the versions listed in this section. This sample will not work on a different version of Node.|
|Refer to <https://aka.ms/spfx-matrix> for more information on SPFx compatibility. |
2021-09-26 10:54:22 -04:00
![SPFx 1.12.1](https://img.shields.io/badge/SPFx-1.12.1-green.svg)
2021-11-01 21:07:49 -04:00
![Node.js v14 | v12 | v10](https://img.shields.io/badge/Node.js-v14%20%7C%20v12%20%7C%20v10-green.svg)
2021-09-26 10:54:22 -04:00
![SharePoint Online](https://img.shields.io/badge/SharePoint-Online-yellow.svg)
![Teams N/A: Untested with Microsoft Teams](https://img.shields.io/badge/Teams-N%2FA-lightgrey.svg "Untested with Microsoft Teams")
![Workbench Hosted](https://img.shields.io/badge/Workbench-Hosted-green.svg)
2022-02-14 02:52:18 -05:00
![Compatible with Remote Containers](https://img.shields.io/badge/Remote%20Containers-Compatible-green.svg)
2016-09-16 00:33:47 -04:00
## Applies to
2022-10-24 09:42:45 -04:00
* [SharePoint Framework](https://learn.microsoft.com/sharepoint/dev/spfx/sharepoint-framework-overview)
* [Microsoft 365 tenant](https://learn.microsoft.com/sharepoint/dev/spfx/set-up-your-development-environment)
2016-09-16 00:33:47 -04:00
2023-02-18 22:58:44 -05:00
## Contributors
2016-09-16 00:33:47 -04:00
2023-03-15 01:23:34 -04:00
* [Waldek Mastykarz](https://github.com/waldekmastykarz)
* [Gautam Sheth](https://github.com/gautamdsheth)
* [Ari Gunawan](https://github.com/AriGunawan)
2016-09-16 00:33:47 -04:00
## Version history
Version|Date|Comments
-------|----|--------
2021-09-26 10:54:22 -04:00
1.4|September 26, 2021|Updated to SPFx 1.12.1
1.3|November 1, 2018|Updated to SPFx 1.6.0
1.2|March 30, 2018|Updated to SPFx 1.4.1
1.1|March 9, 2017|Updated to SPFx GA
2016-09-16 00:33:47 -04:00
1.0|September 16, 2016|Initial release
2021-09-26 10:54:22 -04:00
## Prerequisites
2016-09-16 00:33:47 -04:00
## Minimal Path to Awesome
- clone this repo
- in the command line run:
- `npm i`
- `gulp serve --nobrowser`
- in your SharePoint Site create a list
2022-02-14 02:52:18 -05:00
> This sample can also be opened with [VS Code Remote Development](https://code.visualstudio.com/docs/remote/remote-overview). Visit https://aka.ms/spfx-devcontainer for further instructions.
2016-09-16 00:33:47 -04:00
> Note: this Site should be located in a Site Collection under the **/sites/** managed path, eg. **https://contoso.sharepoint.com/sites/my-team-site**
- navigate to the hosted version of SharePoint workbench, eg. **https://contoso.sharepoint.com/sites/my-team-site/_layouts/15/workbench.aspx**
2016-09-16 00:33:47 -04:00
- add the Web Part to canvas and in its configuration specify:
- name of the lists where items should be stored, eg. **Items**
## Features
This project contains sample client-side web parts built on the SharePoint Framework illustrating how to perform SharePoint CRUD operations on different JavaScript frameworks.
2016-09-16 00:33:47 -04:00
This sample illustrates the following concepts on top of the SharePoint Framework:
- general
- performing SharePoint CRUD operations
- in React
- in Angular v1.x
- without a particular JavaScript framework
- using the [@pnp/sp library](https://github.com/PnP/PnPJS)
2016-09-16 00:33:47 -04:00
- using ETag to ensure data integrity when updating and deleting items
- chaining promises for performing multiple asynchronous operations as part of one use case
- breaking a chain of promises in case of an error and handling it gracefully
- retrieving List Item Entity Type for modelling items in REST requests
- optimizing REST responses for performance
- React
- using Office UI Fabric React components
- using state to keep track of Web Part status and data
- using Web Part's HttpClient in a React component
- Angular
- loading Angular and [ngOfficeUIFabric](http://ngofficeuifabric.com) from CDN
- using conditional rendering for one-time Web Part setup
- passing Web Part configuration to Angular and reacting to configuration changes in the Angular application
- @pnp/sp library
- using the @pnp/sp JS library with SharePoint Framework Client-Side Web Parts
2016-09-16 00:33:47 -04:00
- configuring global request headers and overriding them for specific requests
- sorting and selecting top n items from a list using the fluent API
2021-09-26 10:54:22 -04:00
## Help
We do not support samples, but we this community is always willing to help, and we want to improve these samples. We use GitHub to track issues, which makes it easy for community members to volunteer their time and help resolve issues.
If you're having issues building the solution, please run [spfx doctor](https://pnp.github.io/cli-microsoft365/cmd/spfx/spfx-doctor/) from within the solution folder to diagnose incompatibility issues with your environment.
2021-11-20 23:55:10 -05:00
If you encounter any issues while using this sample, [create a new issue](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected%2Csample%3A%20sharepoint-crud&template=bug-report.yml&sample=sharepoint-crud&authors=@waldekmastykarz%20@AriGunawan%20gautamdsheth&title=sharepoint-crud%20-%20).
2021-09-26 10:54:22 -04:00
2021-11-20 23:55:10 -05:00
For questions regarding this sample, [create a new question](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Aquestion%2Csample%3A%20sharepoint-crud&template=question.yml&sample=sharepoint-crud&authors=@waldekmastykarz%20@AriGunawan%20gautamdsheth&title=sharepoint-crud%20-%20).
2021-09-26 10:54:22 -04:00
2021-11-20 23:55:10 -05:00
Finally, if you have an idea for improvement, [make a suggestion](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Aenhancement%2Csample%3A%20sharepoint-crud&template=question.yml&sample=sharepoint-crud&authors=@waldekmastykarz%20@AriGunawan%20gautamdsheth&title=sharepoint-crud%20-%20).
2021-09-26 10:54:22 -04:00
2021-11-07 02:11:17 -05:00
## Disclaimer
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
2023-03-12 21:16:15 -04:00
<img src="https://m365-visitor-stats.azurewebsites.net/sp-dev-fx-webparts/samples/sharepoint-crud" />