둥근 별점과 반쪽 별Round stars and half stars
rating 렌더러에 shape: 'soft'를 주면 글자 별(★☆) 대신 모서리가 둥근 SVG 별을 그려요. half: true면 0.5 단위로 반올림해 반쪽 별도 보여요. 접근성 이름은 같고 소수로 읽혀요.Give the rating renderer shape: 'soft' to draw rounded SVG stars instead of the ★☆ glyphs. With half: true values round to 0.5 and half stars are drawn. The accessible name stays the same and reads the decimal.
코드Code
탭을 골라 코드를 복사하세요. 위 화면은 이 코드를 그대로 실행한 결과예요.Pick a tab and copy the code. The preview above runs exactly this code.
버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<div id="app">
<div class="toolbar">
<button type="button" id="iconStyle">아이콘 스타일 바꾸기</button>
</div>
<div id="grid" style="height: 360px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { actions, options } from './example';
const api = createGrid(document.getElementById('grid'), options);
document.getElementById('iconStyle').addEventListener('click', () => actions.iconStyle(api));const en = document.documentElement.dataset.lang === 'en';
const names = en
? ['Desk lamp', 'Notebook', 'Keyboard', 'Headset', 'Backpack', 'Mug']
: ['스탠드', '노트', '키보드', '헤드셋', '백팩', '머그컵'];
const reviews = [4.5, 3, 5, 2.5, null, 3.5];
export const options = {
columns: [
{ id: 'product', title: en ? 'Product' : '상품', width: 140 },
{
id: 'review',
title: en ? 'Rating' : '평점',
width: 170,
cellRenderer: 'rating',
// shape: 'soft'는 둥근 SVG 별, half: true는 0.5 단위(반쪽 별)예요. 둘 다 생략하면 예전 글자 별이에요.
cellRendererParams: { shape: 'soft', half: true },
},
{
id: 'plain',
title: en ? 'Glyph stars' : '글자 별',
width: 130,
cellRenderer: 'rating',
},
],
rows: names.map((product, i) => ({
id: i + 1,
product,
review: reviews[i] ?? null,
plain: reviews[i] ?? null,
})),
rowKey: 'id',
rowHeight: 40,
};
export const actions = {
// iconStyle: 'soft'면 shape를 생략한 별점도 둥근 별이 돼요(오른쪽 "글자 별" 열).
iconStyle: (api) => api.setOptions({ iconStyle: api.getOptions().iconStyle === 'soft' ? 'default' : 'soft' }),
};<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>둥근 별점과 반쪽 별</title>
</head>
<body>
<div class="toolbar">
<button type="button" id="iconStyle">아이콘 스타일 바꾸기</button>
</div>
<div id="grid" style="height: 360px"></div>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const en = document.documentElement.dataset.lang === 'en';
const names = en
? ['Desk lamp', 'Notebook', 'Keyboard', 'Headset', 'Backpack', 'Mug']
: ['스탠드', '노트', '키보드', '헤드셋', '백팩', '머그컵'];
const reviews = [4.5, 3, 5, 2.5, null, 3.5];
const options = {
columns: [
{ id: 'product', title: en ? 'Product' : '상품', width: 140 },
{
id: 'review',
title: en ? 'Rating' : '평점',
width: 170,
cellRenderer: 'rating',
// shape: 'soft'는 둥근 SVG 별, half: true는 0.5 단위(반쪽 별)예요. 둘 다 생략하면 예전 글자 별이에요.
cellRendererParams: { shape: 'soft', half: true },
},
{
id: 'plain',
title: en ? 'Glyph stars' : '글자 별',
width: 130,
cellRenderer: 'rating',
},
],
rows: names.map((product, i) => ({
id: i + 1,
product,
review: reviews[i] ?? null,
plain: reviews[i] ?? null,
})),
rowKey: 'id',
rowHeight: 40,
};
const actions = {
// iconStyle: 'soft'면 shape를 생략한 별점도 둥근 별이 돼요(오른쪽 "글자 별" 열).
iconStyle: (api) => api.setOptions({ iconStyle: api.getOptions().iconStyle === 'soft' ? 'default' : 'soft' }),
};
options.ariaLabel = "둥근 별점과 반쪽 별";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
document.getElementById('iconStyle').addEventListener('click', () => actions.iconStyle(api));
</script>
</body>
</html>버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
return (
<>
<div className="toolbar">
<button
type="button"
disabled={!api}
onClick={() => api && actions.iconStyle(api)}
>아이콘 스타일 바꾸기</button>
</div>
<Grid style={{ height: 360 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
const en = document.documentElement.dataset.lang === 'en';
export interface Row {
id: number;
product: string;
review: number | null;
plain: number | null;
}
const names = en
? ['Desk lamp', 'Notebook', 'Keyboard', 'Headset', 'Backpack', 'Mug']
: ['스탠드', '노트', '키보드', '헤드셋', '백팩', '머그컵'];
const reviews = [4.5, 3, 5, 2.5, null, 3.5];
export const options: GridOptions<Row> = {
columns: [
{ id: 'product', title: en ? 'Product' : '상품', width: 140 },
{
id: 'review',
title: en ? 'Rating' : '평점',
width: 170,
cellRenderer: 'rating',
// shape: 'soft'는 둥근 SVG 별, half: true는 0.5 단위(반쪽 별)예요. 둘 다 생략하면 예전 글자 별이에요.
cellRendererParams: { shape: 'soft', half: true },
},
{
id: 'plain',
title: en ? 'Glyph stars' : '글자 별',
width: 130,
cellRenderer: 'rating',
},
],
rows: names.map((product, i) => ({
id: i + 1,
product,
review: reviews[i] ?? null,
plain: reviews[i] ?? null,
})),
rowKey: 'id',
rowHeight: 40,
};
export const actions = {
// iconStyle: 'soft'면 shape를 생략한 별점도 둥근 별이 돼요(오른쪽 "글자 별" 열).
iconStyle: (api: GridApi<Row>) =>
api.setOptions({ iconStyle: api.getOptions().iconStyle === 'soft' ? 'default' : 'soft' }),
};버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<script setup lang="ts">
import { shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { actions, options, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
}
</script>
<template>
<div class="toolbar">
<button
type="button"
:disabled="!api"
@click="api && actions.iconStyle(api)"
>아이콘 스타일 바꾸기</button>
</div>
<Grid style="height: 360px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
const en = document.documentElement.dataset.lang === 'en';
export interface Row {
id: number;
product: string;
review: number | null;
plain: number | null;
}
const names = en
? ['Desk lamp', 'Notebook', 'Keyboard', 'Headset', 'Backpack', 'Mug']
: ['스탠드', '노트', '키보드', '헤드셋', '백팩', '머그컵'];
const reviews = [4.5, 3, 5, 2.5, null, 3.5];
export const options: GridOptions<Row> = {
columns: [
{ id: 'product', title: en ? 'Product' : '상품', width: 140 },
{
id: 'review',
title: en ? 'Rating' : '평점',
width: 170,
cellRenderer: 'rating',
// shape: 'soft'는 둥근 SVG 별, half: true는 0.5 단위(반쪽 별)예요. 둘 다 생략하면 예전 글자 별이에요.
cellRendererParams: { shape: 'soft', half: true },
},
{
id: 'plain',
title: en ? 'Glyph stars' : '글자 별',
width: 130,
cellRenderer: 'rating',
},
],
rows: names.map((product, i) => ({
id: i + 1,
product,
review: reviews[i] ?? null,
plain: reviews[i] ?? null,
})),
rowKey: 'id',
rowHeight: 40,
};
export const actions = {
// iconStyle: 'soft'면 shape를 생략한 별점도 둥근 별이 돼요(오른쪽 "글자 별" 열).
iconStyle: (api: GridApi<Row>) =>
api.setOptions({ iconStyle: api.getOptions().iconStyle === 'soft' ? 'default' : 'soft' }),
};버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { Component } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { actions, options, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<div class="toolbar">
<button
type="button"
[disabled]="!api"
(click)="api && actions.iconStyle(api)"
>아이콘 스타일 바꾸기</button>
</div>
<mx-grid style="height: 360px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent {
readonly options = options;
readonly actions = actions;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
}
}
}import type { GridApi, GridOptions } from '@maxgrid/angular';
const en = document.documentElement.dataset.lang === 'en';
export interface Row {
id: number;
product: string;
review: number | null;
plain: number | null;
}
const names = en
? ['Desk lamp', 'Notebook', 'Keyboard', 'Headset', 'Backpack', 'Mug']
: ['스탠드', '노트', '키보드', '헤드셋', '백팩', '머그컵'];
const reviews = [4.5, 3, 5, 2.5, null, 3.5];
export const options: GridOptions<Row> = {
columns: [
{ id: 'product', title: en ? 'Product' : '상품', width: 140 },
{
id: 'review',
title: en ? 'Rating' : '평점',
width: 170,
cellRenderer: 'rating',
// shape: 'soft'는 둥근 SVG 별, half: true는 0.5 단위(반쪽 별)예요. 둘 다 생략하면 예전 글자 별이에요.
cellRendererParams: { shape: 'soft', half: true },
},
{
id: 'plain',
title: en ? 'Glyph stars' : '글자 별',
width: 130,
cellRenderer: 'rating',
},
],
rows: names.map((product, i) => ({
id: i + 1,
product,
review: reviews[i] ?? null,
plain: reviews[i] ?? null,
})),
rowKey: 'id',
rowHeight: 40,
};
export const actions = {
// iconStyle: 'soft'면 shape를 생략한 별점도 둥근 별이 돼요(오른쪽 "글자 별" 열).
iconStyle: (api: GridApi<Row>) =>
api.setOptions({ iconStyle: api.getOptions().iconStyle === 'soft' ? 'default' : 'soft' }),
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<div id="app">
<div class="toolbar">
<button type="button" id="iconStyle">Toggle icon style</button>
</div>
<div id="grid" style="height: 360px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { actions, options } from './example';
const api = createGrid(document.getElementById('grid'), options);
document.getElementById('iconStyle').addEventListener('click', () => actions.iconStyle(api));const names = ['Desk lamp', 'Notebook', 'Keyboard', 'Headset', 'Backpack', 'Mug'];
const reviews = [4.5, 3, 5, 2.5, null, 3.5];
export const options = {
columns: [
{ id: 'product', title: 'Product', width: 140 },
{
id: 'review',
title: 'Rating',
width: 170,
cellRenderer: 'rating',
// shape: 'soft' is a rounded SVG star and half: true allows 0.5 steps (half stars). Omit both for the old glyph stars.
cellRendererParams: { shape: 'soft', half: true },
},
{
id: 'plain',
title: 'Glyph stars',
width: 130,
cellRenderer: 'rating',
},
],
rows: names.map((product, i) => ({
id: i + 1,
product,
review: reviews[i] ?? null,
plain: reviews[i] ?? null,
})),
rowKey: 'id',
rowHeight: 40,
};
export const actions = {
// With iconStyle: 'soft', a rating without shape also becomes rounded stars (the "Glyph stars" column on the right).
iconStyle: (api) => api.setOptions({ iconStyle: api.getOptions().iconStyle === 'soft' ? 'default' : 'soft' }),
};<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Round stars and half stars</title>
</head>
<body>
<div class="toolbar">
<button type="button" id="iconStyle">Toggle icon style</button>
</div>
<div id="grid" style="height: 360px"></div>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const names = ['Desk lamp', 'Notebook', 'Keyboard', 'Headset', 'Backpack', 'Mug'];
const reviews = [4.5, 3, 5, 2.5, null, 3.5];
const options = {
columns: [
{ id: 'product', title: 'Product', width: 140 },
{
id: 'review',
title: 'Rating',
width: 170,
cellRenderer: 'rating',
// shape: 'soft' is a rounded SVG star and half: true allows 0.5 steps (half stars). Omit both for the old glyph stars.
cellRendererParams: { shape: 'soft', half: true },
},
{
id: 'plain',
title: 'Glyph stars',
width: 130,
cellRenderer: 'rating',
},
],
rows: names.map((product, i) => ({
id: i + 1,
product,
review: reviews[i] ?? null,
plain: reviews[i] ?? null,
})),
rowKey: 'id',
rowHeight: 40,
};
const actions = {
// With iconStyle: 'soft', a rating without shape also becomes rounded stars (the "Glyph stars" column on the right).
iconStyle: (api) => api.setOptions({ iconStyle: api.getOptions().iconStyle === 'soft' ? 'default' : 'soft' }),
};
options.ariaLabel = "Round stars and half stars";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
document.getElementById('iconStyle').addEventListener('click', () => actions.iconStyle(api));
</script>
</body>
</html>When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
return (
<>
<div className="toolbar">
<button
type="button"
disabled={!api}
onClick={() => api && actions.iconStyle(api)}
>Toggle icon style</button>
</div>
<Grid style={{ height: 360 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export interface Row {
id: number;
product: string;
review: number | null;
plain: number | null;
}
const names = ['Desk lamp', 'Notebook', 'Keyboard', 'Headset', 'Backpack', 'Mug'];
const reviews = [4.5, 3, 5, 2.5, null, 3.5];
export const options: GridOptions<Row> = {
columns: [
{ id: 'product', title: 'Product', width: 140 },
{
id: 'review',
title: 'Rating',
width: 170,
cellRenderer: 'rating',
// shape: 'soft' is a rounded SVG star and half: true allows 0.5 steps (half stars). Omit both for the old glyph stars.
cellRendererParams: { shape: 'soft', half: true },
},
{
id: 'plain',
title: 'Glyph stars',
width: 130,
cellRenderer: 'rating',
},
],
rows: names.map((product, i) => ({
id: i + 1,
product,
review: reviews[i] ?? null,
plain: reviews[i] ?? null,
})),
rowKey: 'id',
rowHeight: 40,
};
export const actions = {
// With iconStyle: 'soft', a rating without shape also becomes rounded stars (the "Glyph stars" column on the right).
iconStyle: (api: GridApi<Row>) =>
api.setOptions({ iconStyle: api.getOptions().iconStyle === 'soft' ? 'default' : 'soft' }),
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<script setup lang="ts">
import { shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { actions, options, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
}
</script>
<template>
<div class="toolbar">
<button
type="button"
:disabled="!api"
@click="api && actions.iconStyle(api)"
>Toggle icon style</button>
</div>
<Grid style="height: 360px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export interface Row {
id: number;
product: string;
review: number | null;
plain: number | null;
}
const names = ['Desk lamp', 'Notebook', 'Keyboard', 'Headset', 'Backpack', 'Mug'];
const reviews = [4.5, 3, 5, 2.5, null, 3.5];
export const options: GridOptions<Row> = {
columns: [
{ id: 'product', title: 'Product', width: 140 },
{
id: 'review',
title: 'Rating',
width: 170,
cellRenderer: 'rating',
// shape: 'soft' is a rounded SVG star and half: true allows 0.5 steps (half stars). Omit both for the old glyph stars.
cellRendererParams: { shape: 'soft', half: true },
},
{
id: 'plain',
title: 'Glyph stars',
width: 130,
cellRenderer: 'rating',
},
],
rows: names.map((product, i) => ({
id: i + 1,
product,
review: reviews[i] ?? null,
plain: reviews[i] ?? null,
})),
rowKey: 'id',
rowHeight: 40,
};
export const actions = {
// With iconStyle: 'soft', a rating without shape also becomes rounded stars (the "Glyph stars" column on the right).
iconStyle: (api: GridApi<Row>) =>
api.setOptions({ iconStyle: api.getOptions().iconStyle === 'soft' ? 'default' : 'soft' }),
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { Component } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { actions, options, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<div class="toolbar">
<button
type="button"
[disabled]="!api"
(click)="api && actions.iconStyle(api)"
>Toggle icon style</button>
</div>
<mx-grid style="height: 360px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent {
readonly options = options;
readonly actions = actions;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
}
}
}import type { GridApi, GridOptions } from '@maxgrid/angular';
export interface Row {
id: number;
product: string;
review: number | null;
plain: number | null;
}
const names = ['Desk lamp', 'Notebook', 'Keyboard', 'Headset', 'Backpack', 'Mug'];
const reviews = [4.5, 3, 5, 2.5, null, 3.5];
export const options: GridOptions<Row> = {
columns: [
{ id: 'product', title: 'Product', width: 140 },
{
id: 'review',
title: 'Rating',
width: 170,
cellRenderer: 'rating',
// shape: 'soft' is a rounded SVG star and half: true allows 0.5 steps (half stars). Omit both for the old glyph stars.
cellRendererParams: { shape: 'soft', half: true },
},
{
id: 'plain',
title: 'Glyph stars',
width: 130,
cellRenderer: 'rating',
},
],
rows: names.map((product, i) => ({
id: i + 1,
product,
review: reviews[i] ?? null,
plain: reviews[i] ?? null,
})),
rowKey: 'id',
rowHeight: 40,
};
export const actions = {
// With iconStyle: 'soft', a rating without shape also becomes rounded stars (the "Glyph stars" column on the right).
iconStyle: (api: GridApi<Row>) =>
api.setOptions({ iconStyle: api.getOptions().iconStyle === 'soft' ? 'default' : 'soft' }),
};