Overview
MKing Admin uses AG Grid for powerful, performant data tables with features like sorting, filtering, pagination, and custom cell renderers. All data grids follow consistent patterns for configuration and customization.Basic Grid Setup
Installing Dependencies
Import Styles
Basic Grid Component
Product Page Grid Example
Column Definitions
src/pages/Product/ProductPage.tsx
Default Column Configuration
src/pages/Product/ProductPage.tsx
Grid Rendering
src/pages/Product/ProductPage.tsx
Client Page Grid Example
Image Cell Renderer
src/pages/client/ClientPage.tsx
Date Formatting Cell Renderer
src/pages/client/ClientPage.tsx
Status Chip Renderer
src/pages/client/ClientPage.tsx
Employee Page Grid Example
Avatar Cell Renderer
src/pages/Employees/EmployeesPage.tsx
Value Getter for Computed Fields
src/pages/Employees/EmployeesPage.tsx
Nested Object Fields
src/pages/Employees/EmployeesPage.tsx
Employee Grid Configuration
src/pages/Employees/EmployeesPage.tsx
Custom Cell Renderers
Clickable Name with Custom Styling
Action Buttons with Tooltips
src/pages/Product/ProductPage.tsx
Gradient Color Swatches
src/pages/Product/ProductPage.tsx
Grid Features
Column Configuration Options
- Basic Properties
- Sorting & Filtering
- Styling
- Custom Rendering
Grid Configuration Options
Data Loading and Updates
Initial Data Load
src/pages/Product/ProductPage.tsx
Updating Rows After Edit
src/pages/Product/ProductPage.tsx
Deleting Rows
src/pages/Product/ProductPage.tsx
Advanced Patterns
Dynamic Column Configuration
Conditional Cell Styling
Header Tooltips
src/pages/Product/ProductPage.tsx
Performance Optimization
Memoize Column Definitions
src/pages/Employees/EmployeesPage.tsx
Memoize Default Column Config
src/pages/Product/ProductPage.tsx
Virtual Scrolling
AG Grid automatically implements virtual scrolling for large datasets. No additional configuration needed for optimal performance.Styling
Custom CSS Classes
Height Configuration
Best Practices
Column Configuration
Column Configuration
- Use
flexfor responsive columns,widthfor fixed-width columns - Enable
floatingFilterfor better user experience - Set appropriate
minWidthto prevent column squishing - Use
headerTooltipto explain complex column headers
Cell Renderers
Cell Renderers
- Keep cell renderers simple and performant
- Avoid complex logic inside cell renderers
- Use Material-UI components for consistency
- Handle null/undefined values gracefully
Performance
Performance
- Memoize column definitions with
useMemo - Use
valueGetterfor computed fields instead of processing data - Enable
suppressRowClickSelectionif not using row selection - Implement pagination for large datasets
User Experience
User Experience
- Always enable sorting and filtering
- Use meaningful column headers
- Implement proper loading states
- Provide visual feedback for actions
Related Documentation
Component Overview
Learn about the overall component architecture
Form Handling
Explore react-hook-form implementation