next-grid-filter-wrapper
v1.0.7
Published

Readme
Next AG Grid Filter Wrapper
A powerful React wrapper component that combines AG Grid with Material UI filters in a beautifully integrated package. This component provides a seamless data grid experience with advanced filtering capabilities.
Features ✨
- 🏗️ AG Grid with Material UI design system
- 🔍 Built-in filter drawer with multiple filter types
- 📊 Supports nested data mapping
- 📱 Responsive and mobile-friendly
- ⚡ Optimized performance with virtualization
- 🎨 Customizable appearance and behavior
Installation 📦
npm install next-grid-filter-wrapper
# or
yarn add next-grid-filter-wrapperUsage 🚀
"use client";
import dynamic from "next/dynamic";
import React, { useCallback, useState, useEffect } from "react";
const NextAgGridWrapper = dynamic(() => import("next-grid-filter-wrapper"), {
ssr: false,
loading: () => <p>Loading grid...</p>,
});
function MyComponent() {
const [rowData, setRowData] = useState([]);
// Define your column definitions
const columnDefs = [
{ field: "id", headerName: "ID" },
{ field: "name", headerName: "Name" },
// ... more columns
];
// Define your filters
const filters = [
{
field: "name",
type: "text",
label: "Name Search",
},
// ... more filters
];
return (
<NextAgGridWrapper
rowData={rowData}
columnDefs={columnDefs}
filters={filters}
pagination={true}
paginationPageSize={10}
/>
);
}
export default MyComponent;Props 🛠️
| Prop | Type | Default | Description |
| -------------------- | -------- | ------- | ------------------------------- |
| rowData | Array | [] | Data to display in the grid |
| columnDefs | Array | [] | AG Grid column definitions |
| filters | Array | [] | Filter configurations |
| keyFieldMapping | Object | {} | Mapping for nested data fields |
| pagination | Boolean | false | Enable pagination |
| paginationPageSize | Number | 10 | Items per page |
| onFilterChange | Function | null | Callback when filters change |
| onResetFilters | Function | null | Callback when filters are reset |
Filter Types 🔍
The component supports several filter types out of the box:
- Text Filter - For string values
- Number Filter - For numeric values with min/max
- Select Filter - Dropdown with custom options
- Checkbox Filter - Boolean values
- Date Filter - Date values
Examples 🎨
Basic Usage
<NextAgGridWrapper rowData={data} columnDefs={columns} pagination={true} />With Filters
<NextAgGridWrapper
rowData={data}
columnDefs={columns}
filters={[
{
field: "status",
type: "select",
label: "Status",
options: [
{ value: "active", label: "Active" },
{ value: "inactive", label: "Inactive" },
],
},
]}
/>With Nested Data
<NextAgGridWrapper
rowData={data}
columnDefs={columns}
keyFieldMapping={{
"user.id": "userId",
"user.name": "userName",
}}
/>Customization 🎛️
You can customize the appearance by:
- Overriding CSS classes
- Providing custom filter components
- Extending default column definitions
const defaultColDef = {
sortable: true,
resizable: true,
filter: true,
// ... your customizations
};
<NextAgGridWrapper
defaultColDef={defaultColDef}
// ... other props
/>;Performance Tips ⚡
- Use
useMemofor column definitions - Implement server-side filtering for large datasets
- Use pagination for datasets > 1000 rows
- Virtualize rows for optimal rendering
Contributing 🤝
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch
- Submit a pull request
License 📄
MIT © [HANNAN AHMED]
- Happy User
