A powerful, feature-rich data grid library that works across all modern frameworks. Built with performance and flexibility in mind.
- π Global Search - Search across all columns with real-time filtering
- π Column Sorting - Click headers to sort ascending/descending, click again to remove sort
- π Smart Pagination - Configurable page sizes with intuitive navigation
- β Row Selection - Single/multi-row selection with "Select All" functionality
- π€ Data Export - Export data to CSV, JSON, or Excel formats (all data or selected rows)
- π¨ Theming - Multiple built-in themes (modern, classic, dark)
- π Action Columns - Button and link columns with custom click handlers
- π± Responsive Design - Works seamlessly on desktop and mobile
- β‘ High Performance - Optimized rendering for large datasets
- π Framework Agnostic - Works with React, Angular, Vue, and vanilla JavaScript
- π― TypeScript Support - Full type definitions included
npm install smart-data-grid
import React, { useState } from "react";
import SmartDataGrid from "smart-data-grid/react";
const MyComponent = () => {
const data = [
{
id: 1,
name: "Alice",
age: 25,
email: "[email protected]",
status: "Active",
},
{
id: 2,
name: "Bob",
age: 30,
email: "[email protected]",
status: "Inactive",
},
{
id: 3,
name: "Charlie",
age: 35,
email: "[email protected]",
status: "Active",
},
];
const columns = [
{ field: "name", header: "Name" },
{ field: "age", header: "Age" },
{ field: "email", header: "Email" },
{
field: "status",
header: "Status",
type: "button",
clickFn: (row) => console.log("Status clicked:", row),
},
{
field: "actions",
header: "Actions",
type: "link",
clickFn: (row) => console.log("Edit:", row),
},
];
const [selectedRows, setSelectedRows] = useState([]);
return (
<SmartDataGrid
dataSource={data}
columns={columns}
title="User Management"
enableSelection={true}
onSelectionChange={setSelectedRows}
defaultSortKey="name"
theme="modern"
searchable={true}
paginationOptions={[5, 10, 25, 50]}
enableExport={true}
exportFormats={["csv", "json", "excel"]}
exportFileName="user-data"
/>
);
};
Prop | Type | Default | Description |
---|---|---|---|
dataSource |
Array<any> |
[] |
Array of data objects to display |
columns |
ColumnConfig[] |
[] |
Column configuration array |
title |
string |
undefined |
Grid title displayed at the top |
enableSelection |
boolean |
false |
Enable row selection checkboxes |
onSelectionChange |
(rows: any[]) => void |
undefined |
Callback when selection changes |
defaultSortKey |
string |
undefined |
Initial column to sort by |
theme |
'modern' | 'classic' | 'dark' |
'modern' |
Visual theme |
searchable |
boolean |
true |
Show global search input |
paginationOptions |
number[] |
[10, 20, 30, 50, 100] |
Available page size options |
enableExport |
boolean |
false |
Enable data export functionality |
exportFormats |
('csv' | 'json' | 'excel')[] |
['csv', 'json'] |
Available export formats |
exportFileName |
string |
'data-export' |
Base filename for exported files |
interface ColumnConfig {
field: string; // Data field key
header: string; // Column header text
sortable?: boolean; // Column sort diable by default true
type?: "text" | "button" | "link"; // Column type
clickFn?: (row: any) => void; // Click handler for button/link types
showLinkConditions?: (row: any) => boolean; // Conditional display logic
}
Attribute | Type | Description |
---|---|---|
data |
string |
JSON stringified array of data |
header |
string |
JSON stringified column configuration |
sortable |
boolean |
Disable sorting |
pagination |
boolean |
Enable pagination |
filter |
boolean |
Enable global search |
theme |
string |
Theme name ('modern', 'classic', 'dark') |
page-size |
number |
Default page size |
enable-selection |
boolean |
Enable row selection |
enable-export |
boolean |
Enable data export functionality |
export-formats |
string |
Comma-separated export formats ('csv,json,excel') |
- Modern - Clean, contemporary design with subtle shadows
- Classic - Traditional table styling with borders
- Dark - Dark mode optimized theme
/* Override CSS custom properties */
.smart-data-grid.modern {
--grid-bg: #ffffff;
--grid-border: #e1e5e9;
--header-bg: #f8f9fa;
--row-hover: #f5f5f5;
--primary-color: #007bff;
--text-color: #212529;
}
.smart-data-grid.dark {
--grid-bg: #1a1a1a;
--grid-border: #404040;
--header-bg: #2d2d2d;
--row-hover: #333333;
--primary-color: #4dabf7;
--text-color: #ffffff;
}
The grid supports exporting data in multiple formats:
// Export all filtered data or just selected rows
<SmartDataGrid
dataSource={data}
columns={columns}
enableExport={true}
exportFormats={["csv", "json", "excel"]}
exportFileName="my-data"
/>
Export Behavior:
- If rows are selected, only selected rows are exported
- If no rows are selected, all filtered/sorted data is exported
- Action columns (buttons/links) are automatically excluded from exports
- Files are downloaded with timestamps to prevent overwrites
Supported Formats:
- CSV - Comma-separated values, Excel compatible
- JSON - Structured JSON format
- Excel - .xls format that opens in Microsoft Excel
const columns = [
{ field: "name", header: "Name" },
{
field: "edit",
header: "Actions",
type: "button",
sortable: false,
clickFn: (row) => {
// Handle edit action
openEditModal(row);
},
},
{
field: "view",
header: "View",
type: "link",
clickFn: (row) => {
// Handle view action
navigateToDetails(row.id);
},
showLinkConditions: (row) => row.status === "Active",
},
];
const handleSelectionChange = (selectedRows) => {
console.log(`${selectedRows.length} rows selected`);
// Bulk operations
if (selectedRows.length > 1) {
showBulkActions();
}
// Update UI state
setCanDelete(selectedRows.length > 0);
};
- Efficient Rendering - Only renders visible rows
- Optimized Sorting - Uses efficient comparison algorithms
- Memory Management - Minimal memory footprint
- Debounced Search - Prevents excessive filtering during typing
- Virtual Scrolling - Coming in v2.0 for ultra-large datasets
<SmartDataGrid
dataSource={employees}
columns={employeeColumns}
title="Employee Directory"
enableSelection={true}
onSelectionChange={handleSelection}
theme="dark"
searchable={true}
enableExport={true}
exportFormats={["csv", "excel"]}
exportFileName="employees"
/>
# Clone repository
git clone https://github.com/cvchauhan/smart-data-grid.git
# Install dependencies
npm install
# Start development server
npm run dev
# Build for production
npm run build
# Run tests
npm test
- β Minore bug fix
- β
You can now disable sorting for specific columns by adding
sortable: false
- β Dark Theme colum selection background color issue resolved
- β Added comprehensive data export functionality
- β Support for CSV, JSON, and Excel export formats
- β Smart export (selected rows or all data)
- β Automatic exclusion of action columns from exports
- β Customizable export filenames
- β Fixed "Select All" to work across all pages
- β Added indeterminate checkbox states
- β Improved row selection persistence
- β Enhanced visual feedback for selections
- β Complete rewrite with modern architecture
- β Added React component support
- β Multi-theme support
- β Advanced column types (button, link)
- β Improved accessibility
- β TypeScript definitions
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
MIT Β© 2025 Chirag Chauhan
- GitHub Repository: https://github.com/cvchauhan/smart-data-grid
- NPM Package: https://www.npmjs.com/package/smart-data-grid
- Issues: https://github.com/cvchauhan/smart-data-grid/issues
If you find this project helpful, please consider:
- β Starring the repository
- π Reporting bugs
- π‘ Suggesting new features
- π Improving documentation
For support, email [email protected] or create an issue on GitHub.