How to do conditional formatting on the SharePoint List field values using SPFx - Field Customizer?
How to do conditional formatting on the SharePoint List field values using SPFx - Field Customizer?
706 Views Asked by Deepika Edakkoth At
1
There are 1 best solutions below
Related Questions in TYPESCRIPT
- Use translateProvider.useLoader with Typescript
- Optional method in base class
- Putting Lambdas in OR statement
- Deleting namespace in Socket IO
- Angularjs+Typescript directive implementing $compile
- Typescript type inference inside for loop
- Why void functions are allowed in left part of assignment in Typescript?
- Tools for Apache Cordova - TypeScript debugger jumps to wrong line
- Typescript - is there a way to specify a global reference?
- How to angularjs app.service and $q in typescript
- include typescript file in output result build with TFS
- Mocking Angular $window in unit test cases
- Difference between `share()` and `publish().refCount()`
- TypeScript: workaround for relative reference path?
- How to define knex migrations using Typescript
Related Questions in SHAREPOINT
- Upload a document to a SharePoint document library (can be via Rest Api/other) using C# & also retrieve the unique id of the document
- Sharepoint alers email deletion from alerts
- SharePoint/CSS3 Gradients/IE9
- Sharepoint 2007 / Jquery - Replace all text on body or render HTML
- share point excel service
- MS Access Run-time error 3999
- Maintain Sharepoint Server Url with subfolders in document list
- How can I integrate a SharePoint document folder in a separate ASP.NET web site?
- why I don't get list subfolders despite using RecursiveAll option
- Modal Extender Ajax Control Toolkit (ASP 2.0) will not pop-up on server side trigger
- Configure SharePoint 2010 UPS with PowerShell
- How can I get Internet explorer to display this image correctly
- Developing Syntax app SharePoint Online PrismJS
- SharePoint 2013 Custom list field iterator not saving values for MultiLine or person columns
- SharePoint Links with Ampersands
Related Questions in SHAREPOINT-ONLINE
- Authenticate User for ASP.NET MVC from Sharepoint
- Update media file properties with managed metadata content in sharepoint online via Office Preview API
- SharePoint 365 Development - Visual Studio 2012 - Actions4 file
- Rest API to upload an image with customized metadata in office 365
- How can i Pull Profile image from sharepoint
- Connect to SharePoint Lists with OData
- Sharepoint Online provider hosted app as a web part
- JSlink changes after creating site from template
- Get user detail from Ad/Exchange online using jquery
- Error validating exception when using System.Reflection
- Get current page URL and Title from a SharePoint Provider Hosted add-in Part?
- Get profile pictures of all users in SharePoint hosted app (SharePoint online Office 365) issue in IE
- “Invalid provider specified” while creating provider-hosted SharePoint Add-ins
- How to map between two site collection lists using SharePoint online?
- Add Project Custom Fields in Task List
Related Questions in SHAREPOINTFRAMEWORK
- Simply edit Sharepoint webpart manifest.json
- How to do conditional formatting on the SharePoint List field values using SPFx - Field Customizer?
- React (SPFx - Sharepoint Framework): Control order of imported css classes
- How do I add an item to sharepoint "New" menu?
- SPFx Unit Testing with newer SPFx and @pnpjs Version
- How to create custom section layout options for SharePoint online modern site pages?
- Function in react-table columnDef shows empty value for property passed from parent component
- How to resolve this plugin sass error in my SharePointFramework?
- Initialising spfxContext for a different user in pnp/sp
- SharePoint Framework (SPFx) -- Web Part Solution Uploaded, Enabled, Not Deploying
- Can we deploy SharePoint framework assets anywhere other than SharePoint CDN and Azure CDN?
- Getting Invalid hook call Hooks can only be called inside of the body of a function component with SharePoint Framework Template
- Tag Picker in SPFx
- Render/edit MS Office docs in browser with SharePoint or WOPI
- APS (Forge) Viewer in Sharepoint - Error loading Autodesk Viewer library
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
SharePoint Framework Field Customizer extensions enable you to customize the format of the field data in SharePoint lists. The Field Customizer is more powerful because you can use it to write any code that you want to control how a field is displayed. Here I give you a quick and simple example to render a Status field value based on conditional formatting on field values SLA Met? and Overdue Hours using SPFx Field Customizer. enter image description here
Let’s assume we have a list with four fields Title, Status, SLA Met? and Overdue Hours. The title is the default column. Status Column is a choice field and has the following values Open, InProgress, Pending, Rejected, Completed, and Closed. SLA Met? column is a Yes/No field and Overdue Hours is a Number field. My requirement was we want to display the Status column value in view form as Status value + Overdue Hours whose SLA Met? is Yes and if Overdue Hours is more than or equal to 48 Hrs then display it like days. Also, display the Status cell with colors based on each Status value.
Solution:
Open the Node.js Command Prompt
Step-1: Create a new project directory in your favorite location. md field-extension
Step-2: Go to the project directory. cd field-extension
Step-3: Create a new DataSupplier extension by running the Yeoman SharePoint Generator. yo @microsoft/sharepoint When prompted, enter the following values (select the default option for all prompts omitted below):
Step-4: What is your solution name? field-extension
Step-5: Will the components in the solution require permissions to access web APIs that are unique and not shared with other components in the tenant? (y/n) n
Step-6: Which type of client-side component to create? Extension
Step-7: Which type of client-side extension to create? Field Customizer
Step-8: What is your Field Customizer name? DataSupplier
Step-9: What is your Field Customizer description? DataSupplier description
Step-10: Which framework would you like to use? No JavaScript Framework
At this point, Yeoman installs the required dependencies and scaffolds the solution files along with the DataSupplier extension. This might take a few minutes.
Step-11: Type the following into the console to start Visual Studio Code. Code.
Step 12: Within Visual Studio Code, open the ./config/serve.json file.
Set the InternalFieldName attribute to Status for the field name, which we created. Update the pageUrl attributes to match a URL of the list. After the changes, your serve.json should look like the following code:
enter image description here
Step-13: Open the .../src\extensions\dataSupplier\DataSupplierFieldCustomizer.ts file.
Here we are using ListItemAccessor class for accessing the list items of the rendered status column. So, we should import the class from the sp-listview-extensibility package.
import { BaseFieldCustomizer, IFieldCustomizerCellEventParameters, ListItemAccessor } from '@microsoft/sp-listview-extensibility';
The following are the content of OnRendercell() methods in the solution. Also we are calling a new function from OnRenderCell() method named _getSLAValue() to check the Overdue Hours.
@override public onRenderCell(event: IFieldCustomizerCellEventParameters): void { // Use this method to perform your custom cell rendering.
Step-14: Build your code in Node.js command prompt gulp build
Step 15: Compile your code by running this command: gulp serve
This will start your default browser and load the page defined in serve.json file.
Step-16: Accept the loading of debugging manifests by selecting Load to debug scripts when prompted.
enter image description here
Now we can see the changes in the list view as shown below.
enter image description here