gridcn2.0.0
Server and data examples

Cell comments example

Write, edit, resolve, and delete comments on cells, first on a client-only grid, then with a simulated second user, a forced conflict, and an offline switch.

The first grid keeps anonymous comments in the local storage of your browser. It has no user and no server.

Open a cell and press Shift+F2, or right-click and choose Comments…. Comments stay in this browser.

Name
Email
Role
Score
Silent Tiger
user0@example.com
Viewer
4
Quick Lion
user1@example.com
Viewer
89
Swift Wolf
user2@example.com
Manager
80
Eager Lion
user3@example.com
User
51
Eager Tiger
user4@example.com
Viewer
83
Silent Wolf
user5@example.com
User
15
Swift Lion
user6@example.com
Viewer
62
Eager Lion
user7@example.com
Manager
42
Eager Eagle
user8@example.com
Editor
35
Bold Tiger
user9@example.com
Editor
52
Bold Bear
user10@example.com
User
28
Swift Wolf
user11@example.com
Manager
9
Swift Bear
user12@example.com
Viewer
45
Eager Wolf
user13@example.com
Editor
44
Swift Eagle
user14@example.com
Viewer
51
Quick Lion
user15@example.com
Manager
28
Bold Wolf
user16@example.com
Editor
76
Swift Eagle
user17@example.com
Admin
26
Eager Eagle
user18@example.com
Manager
70
Eager Bear
user19@example.com
Editor
67
Silent Lion
user20@example.com
Manager
89
Silent Tiger
user21@example.com
Manager
40
Eager Tiger
user22@example.com
Manager
82
Silent Lion
user23@example.com
Admin
16
pnpm dlx shadcn@latest add @gridcn/data-grid-comments-demo

Comments on a server

The second grid saves each comment write to an in-memory server with about 400 ms of latency. The server accepts a write only when its baseVersion equals the stored version. Press Shift+F2 on a cell, or right-click a cell and choose "Comments…". A second user, Grace, writes comments through applyRemote.

Open a cell and press Shift+F2, or right-click and choose Comments…

Name
Email
Role
Score
Silent Tiger
user0@example.com
Viewer
4
Quick Lion
user1@example.com
Viewer
89
Swift Wolf
user2@example.com
Manager
80
Eager Lion
user3@example.com
User
51
Eager Tiger
user4@example.com
Viewer
83
Silent Wolf
user5@example.com
User
15
Swift Lion
user6@example.com
Viewer
62
Eager Lion
user7@example.com
Manager
42
Eager Eagle
user8@example.com
Editor
35
Bold Tiger
user9@example.com
Editor
52
Bold Bear
user10@example.com
User
28
Swift Wolf
user11@example.com
Manager
9
Swift Bear
user12@example.com
Viewer
45
Eager Wolf
user13@example.com
Editor
44
Swift Eagle
user14@example.com
Viewer
51
Quick Lion
user15@example.com
Manager
28
Bold Wolf
user16@example.com
Editor
76
Swift Eagle
user17@example.com
Admin
26
Eager Eagle
user18@example.com
Manager
70
Eager Bear
user19@example.com
Editor
67
Silent Lion
user20@example.com
Manager
89
Silent Tiger
user21@example.com
Manager
40
Eager Tiger
user22@example.com
Manager
82
Silent Lion
user23@example.com
Admin
16
pnpm dlx shadcn@latest add @gridcn/data-grid-comments-server-demo

The buttons above the grid try the other paths:

  • Grace adds a comment sends a change from another client through applyRemote. The comment marker shows without a reload.
  • Grace edits a comment (force a conflict) changes your first comment on the server. Write a comment first, press the button, and then edit your comment. The server refuses the save as stale, and the popover offers Save my version and Discard.
  • Go offline makes every save throw. The popover keeps your text and offers Retry.

The server demo passes onCommentSave to call the server, onLocalChange and onCommentRejected to log each result, and getCommentMenuItems to the context menu. For the same wiring in your own app, see Add comments to cells.

On this page