This article explains how to use the SharePoint Framework (SPFx) to create a Field Customizer extension for SharePoint. Depending on certain criteria, the extension will format a numeric field in a SharePoint list to emphasize values with colored backgrounds.
This is a step-by-step guide on creating a Field Customizer extension.
Step 1: Use the Yeoman SharePoint Generator to create a new HelloWorld extension.
yo @microsoft/sharepoint
Step 2. When prompted, enter the following values.
- What is your solution name?: field-extension
- Which type of client-side component to create?: Extension
- Which type of client-side extension to create?: Field Customizer
- What is your Field Customizer name?: HelloWorld
- Which template would you like to use?: No JavaScript Framework
Step 3. To test your extension, you’ll need to first create the field to test the customizer. So move to the site in your SharePoint Online tenant where you want to test the field customizer.
Navigate to the Site Contents page.
On the toolbar, select New, and then select List.
Create a new list named Orders, and then select Create.
Select the + sign, and then select Number to create a new Number field for the list. Set the name of the field to Percent, and then select Save.Add a few items with different numbers in the percent field. We’ll modify the rendering later in this tutorial, so the different numbers will be presented differently based on your custom implementation.
Step 4. Within Visual Studio Code, open the ./config/serve.json file.
Set the InternalFieldName attribute to Percent for the field name, which we created. Update the page URL attributes to match the URL of the list that we created in the preview steps. After the changes, your serve.json should look like the following code.
Step 5. Compile your code and host the compiled files from the local machine by running this command.
Step 6. After successful compilation, Notice how the Percent column values are now presented with an additional prefix string as Value:, which is provided as a property for the Field Customizer.
Step 7. Let’s enhance this some more. Open the ./src/extensions/helloWorld/HelloWorldFieldCustomizer.module.scss file, and update the styling definition as follows.
Step 8. Open the file ./src/extensions/helloWorld/HelloWorldFieldCustomizer.ts and update the onRenderCell() method as follows.
Step 9. Save the code and see how the list looks changed.
A graphical representation of the field value is indicated.
Note
- Use your own GUID and project names where applicable.
- You can expand the logic in onRenderCell to fit your specific needs, such as rendering HTML, React components, or icons.
Conclusion
The Field Customizer extension enhances the SharePoint user experience by adding conditional formatting and improving readability in list views. You can further extend this logic to include icons, advanced formatting, or even interactive features.
Which Provider who can Give You The Best and Recommended SharePoint 2013 Hosting?
Happily, there are several reliable and recommended Web hosting out there that can help you get a handle on site speed and work to increase Which Provider who can Give You The Best and Recommended SharePoint 2013 Hosting?
Happily, there are several reliable and recommended Web hosting out there that can help you get a handle on site speed and work to increase your SharePoint 2013 web rank. We are here to recommend you HostForLIFE.eu. HostForLIFE.eu is the most popular choice for people looking to host for the first time at an affordable price in Europe.
Their Sharepoint Plan price starts at €9.99/month only. Customers are allowed to decide on quarterly and annual plan supported their own desires. HostForLIFE.eu guarantees “No Hidden Fees” and industry leading ‘30 Days Cash Back’, folks might ask for a full refund if they cancel the service at intervals the first thirty days.
HostForLIFE.eu also give their customers an opportunity to create some cash by providing reseller hosting accounts. you’ll purchase their reseller hosting account, host unlimited websites thereon and even have the prospect to sell a number of your hosting area to others. This could be one amongst the best ways that of creating some cash on-line. You are doing not have to be compelled to worry concerning hosting stuff as they’ll beware of all the hosting desires of your shoppers.your SharePoint 2013 web rank. We are here to recommend you HostForLIFE.eu. HostForLIFE.eu is the most popular choice for people looking to host for the first time at an affordable price in Europe.