Column Type Rate
RatingColumnType
The RatingColumnType class defines a custom column type for the RevoGrid, specifically
designed to handle and render rating values as a series of star icons. This custom type
includes a validation method to ensure rating values are within an acceptable range (0 to 5)
and a cellTemplate
method for rendering the visual representation of these ratings.
Key Features:
- Validation: Ensures rating values are between 0 and 5, inclusive.
- Custom cell rendering: Displays rating as stars, using a
cellTemplate
function to map numeric values to visual elements.
Usage:
- Implement the RatingColumnType in the grid’s column configuration to apply this rating visualization logic.
- Utilize the
cellTemplate
function provided by this class within your column definitions to render ratings.
Example
import { RatingColumnType } from './rating-column-type';
const grid = document.createElement('revo-grid');grid.columns = [ { prop: 'rating', name: 'User Rating', cellTemplate: RatingColumnType.prototype.cellTemplate, // Apply custom rating cell template },];
This class enhances the grid’s capability to visually represent rating data, facilitating a more intuitive user experience for reviewing rating values.
class RatingColumnType {}