Skip to content

Commit

Permalink
refactor: cellRendererを使うことで画面移遷のパフォーマンスを向上
Browse files Browse the repository at this point in the history
  • Loading branch information
testusuke committed Apr 24, 2024
1 parent 7e7085c commit efb6f45
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
15 changes: 15 additions & 0 deletions components/users/userLinkRenderer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {ICellRendererParams} from "ag-grid-community";
import Link from "next/link";

export default function UserLinkRenderer(param: ICellRendererParams) {
return (
<Link
href={`/users/${param.value}`}
style={{
width: '100%',
}}
>
{param.value}
</Link>
)
}
7 changes: 6 additions & 1 deletion components/users/usersAgGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {User} from "@/src/models/UserModel";
import {Class} from '@/src/models/ClassModel';
import {Team} from "@/src/models/TeamModel";
import {useRouter} from "next/navigation";
import UserLinkRenderer from "@/components/users/userLinkRenderer";

ModuleRegistry.registerModules([ClientSideRowModelModule]);

Expand Down Expand Up @@ -38,7 +39,11 @@ const UsersAgGrid = (props: UsersAgGridProps) => {
const [rowData, setRowData] = useState<IRow[]>([])
// Column Definitions: Defines & controls grid columns.
const [colDefs,] = useState<ColDef<IRow>[]>([
{field: "userId", headerName: "ユーザーID"},
{
field: "userId",
headerName: "ユーザーID",
cellRenderer: UserLinkRenderer,
},
{
field: "name",
headerName: "名前",
Expand Down

0 comments on commit efb6f45

Please sign in to comment.