Skip to main content

TimePicker PCF Control

 

1. Overview

The Time Picker Control is a UI component that allows users to select a time value. It provides a user-friendly interface with options to manually input or select a time from a dropdown. This control ensures accurate time selection while improving the user experience.

2. Features

  • Select time using a dropdown or manual input.
  • Supports 12-hour and 24-hour formats.
  • Validation to prevent incorrect time inputs.
  • Customizable UI to match application themes.
  • Option to set minimum and maximum time limits.
  • Events for capturing value changes.

3. Usage Scenarios

  • Scheduling appointments or meetings.
  • Setting alarms or reminders.
  • Configuring time-based automation tasks.

4. Implementation Details

4.1 Dependencies

The control requires the following dependencies:

  • HTML and CSS for structuring and styling.
  • JavaScript for functionality.
  • Optionally, a third-party library like flatpickr for extended features.

4.2 HTML Structure

<div class="time-picker">
    <input type="time" id="timeInput" />
</div>

4.3 JavaScript Logic

document.addEventListener("DOMContentLoaded", function () {
    const timeInput = document.getElementById("timeInput");
    
    timeInput.addEventListener("change", function () {
        console.log("Selected Time:", timeInput.value);
    });
});

4.4 Styling (CSS)

.time-picker input {
    width: 150px;
    padding: 5px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 5px;
}

5. Customization Options

  • Format: Choose between 12-hour (hh:mm AM/PM) or 24-hour (HH:mm) format.
  • Min/Max Time: Define allowed time range.
  • Styling: Modify CSS to match branding.

6. Event Handling

  • onChange: Trigger actions when time is selected.
  • onFocus: Show time picker when input is focused.
  • onBlur: Validate input when focus is lost.

7. Error Handling

  • Prevents invalid time formats.
  • Alerts users when input is out of range.

8. Conclusion

The Time Picker Control enhances user experience by simplifying time selection. It is lightweight, customizable, and easy to integrate into various applications.










Comments

Popular posts from this blog

Contacts View PCF Control

  1. Overview The ContactsControl component is a custom PowerApps control that displays a searchable and sortable table of contact records. It provides an interactive UI for filtering and selecting records. 2. Functionalities Search Feature: Allows users to filter records by entering text. Sorting: Clickable column headers enable ascending/descending sorting. Record Selection: Users can select a record to trigger a modal alert. Dynamic Rendering: Updates view dynamically based on search and sort input. Custom Styling: Uses external CSS for styling. 3. Component Structure Main Container ( HTMLDivElement ) : Holds the search bar and table. Search Input ( HTMLInputElement ) : Enables real-time search. Table ( HTMLTableElement ) : Displays the records with sortable headers. Modal Alert ( HTMLDivElement ) : Displays selected record details. 4. Implementation Details 4.1 Initialization ( init Method) Sets up the main container. Loads external styles. Creates...

Attachment PCF

Overview The AttachmentControl component is a PowerApps Component Framework (PCF) control designed for handling file uploads. It supports multiple file uploads, drag-and-drop functionality, file previews, and base64 encoding for easy data handling. Features Supports multiple file uploads Drag-and-drop functionality File type and size validation Base64 conversion for uploaded files Preview support for images, PDFs, and text files File removal functionality Code Breakdown Importing Dependencies import { IInputs, IOutputs } from "./generated/ManifestTypes"; The component imports IInputs and IOutputs from the generated manifest file to define the control's input and output types. Component Definition export class AttachmentControl implements ComponentFramework.StandardControl<IInputs, IOutputs> { Defines the AttachmentControl class, implementing the StandardControl interface from PCF. Class Variables private container: HTMLDivElement; private fileInput: HTMLInputEl...

Trigger JavaScript on Click of Button PCF Control

  Overview The TriggerJavascript control is a custom PCF (PowerApps Component Framework) control that renders a button with customizable label, icon, and on-click script execution. The control allows users to dynamically trigger JavaScript code upon clicking the button. Dependencies IInputs, IOutputs from ./generated/ManifestTypes (Auto-generated types from PowerApps) CSS styling from ./CSS/TriggerJavascript.css Class: TriggerJavascript This class implements ComponentFramework.StandardControl<IInputs, IOutputs> and manages rendering a button inside a container, dynamically executing JavaScript code on button click. Properties Private Properties _container: HTMLDivElement - A reference to the container element where the button will be rendered. Methods constructor() Initializes a new instance of the TriggerJavascript control. init(context: ComponentFramework.Context<IInputs>, notifyOutputChanged: () => void, state: ComponentFramework.Dictionary, container: HTMLD...