Build SharePoint Framework client side web part – III

 

 

 

 

 

Suggested Articles

 

What is SharePoint Framework (SPFx)

Future prospects of SharePoint Framework (SPFx)

Required tools and libraries for SharePoint Framework (SPFx) development

Setup Office 365 tenant for SharePoint Framework development

Setup SharePoint Framework client side web part development environment

Build SharePoint client side web part using SharePoint Framework (SPFx) – I

Build SharePoint client side web part using SharePoint Framework (SPFx) – II

 

It is a continuation of last article on SharePoint Framework Client Side Web Part development.

Configure web part property pane

Property Pane is defined in SharePoint Framework web part itself. In my case, it is in defined in HelloWorldWebPart.ts file. I’ll be adding one new Toggle field in web part property pane.

 



 

Before starting the steps, let me share information that these controls are automatically added with this project by Yeoman. You can see a package under

/node_modules/@microsoft/sp-webpart-base/lib/propertyPane/propertyPaneFields/propertyPaneToggle

Wow! It reminded me the time of programming in C/C++ on Turbo C. Packages are same as header files.

Let’s continue with the steps:

Add new field “customToggle” as boolean type in IHelloWebPartProps.ts

 

sharepoint-client-side-webpart-iii-1

 

Add this field in exiting group of Property Pane in web part.

File Name: HelloWorldWebPart.ts

Additional Code: Highlighted in screen shot below

 

sharepoint-client-side-webpart-iii-2

 



 

Now, add below statement in class HelloWorldWenPart available in file HelloWorldWebPart.ts

<p class=”ms-font-l ms-fontColor-white”>${this.properties.customToggle}</p>

 

sharepoint-client-side-webpart-iii-3

 

Import PropertyPaneToggle from @microsoft/sp-webpart-base. You need to add highlighted text in HelloWorldWebPart.ts

 

sharepoint-client-side-webpart-iii-4

 

Now, add default value of newly added property as True in HelloWorldWebPart.manifest.json file. This file is a manifest file of web part which defines web part metadata. Every web part should has this manifest file.

 

sharepoint-client-side-webpart-iii-5

 

Let’s run the project now. Open command prompt and run following command in current web part’s root directory i.e. helloworld-webpart

 



 

gulp serve

It will run the project and launch workbench.html in browser. Just add your web part on the page.

 

sharepoint-client-side-webpart-iii-6

 

You will see page as below

 

sharepoint-client-side-webpart-iii-7

 



 

Click edit icon (i.e. pencil image) on top left corner, it will open web part property pane on right side of desktop.

 

sharepoint-client-side-webpart-iii-8

 

As soon as you toggle the switch, you will see changes in value on web part false or true. Refer the screen shot below.

 

sharepoint-client-side-webpart-iii-9

 

And, That’s done 🙂



What’s next?

Well, we’ll go deep in SharePoint Framework programming further and see how can we consume REST APIs in SharePoint Framework (SPFx) web parts? One more thing, we’ll also see, how to debug SharePoint Framework projects in Visual Studio Code?

Hey, in command prompt, why do you not run CTRL+C to stop GULP?

 

Thank you for reading!

 



 

 

 

 

 

THREE QUERIES offers easy access to information about business, management, technology and spirituality that helps people and has grown from there. We provide an important knowledge base for those involved in managing, architecture and developing projects of all kinds. With weekly exclusive updates, we keep you in touch with the latest business, management, technology and spirituality thinking.

WE ARE CONNECTED ~ Follow us on social media to get regular updates and opinion on what's happening in the world of SharePoint, front-end, back end web technologies and project management. If you like this article, please share it and follow us at Facebook, Twitter, Instagram, Pinterest and LinkedIn

About Satyendra Mishra

Microsoft certified, motivated, energetic and accomplished SharePoint Consultant and Architect with 13+ years of work experience in Management, Architecture, Analytics, Development and Maintenance. He has been fortunate to be a part of over 20+ Web/Mobile/Software SharePoint and .Net projects delivery with various companies across different industry sectors. This has provided him a valuable insight and experience especially in successful implementation of technology solutions. Having very strong System Architecture, Technological, Management & Analytical Skills, Knowledge of Office 365, SharePoint, .Net, JavaScript, React, Angular, Azure, SQL. In 2016, he decided to start sharing the knowledge back to society in the form for content writing and blogging.
View all posts by Satyendra Mishra →

Leave a Reply

Your email address will not be published. Required fields are marked *