PHPackages                             bytestechnolabs/datagrid - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. bytestechnolabs/datagrid

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

bytestechnolabs/datagrid
========================

1.0(2y ago)114MITBlade

Since Apr 22Pushed 2y ago1 watchersCompare

[ Source](https://github.com/bhavik-bytescoder/package-laravel-custom-grid)[ Packagist](https://packagist.org/packages/bytestechnolabs/datagrid)[ RSS](/packages/bytestechnolabs-datagrid/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Custom DataGrid
===============

[](#custom-datagrid)

Custom DataGrid is a powerful Laravel package that simplifies the process of creating dynamic grids with minimal code. With features like Bootstrap 5 compatibility, CSV and TSV exporting, sorting, searching, and inline or bulk actions, managing tabular data becomes a breeze. This README will guide you through the installation and configuration process, ensuring you harness the full potential of Custom DataGrid.

Table of Contents
-----------------

[](#table-of-contents)

- [Custom DataGrid](#custom-datagrid)
    - [Table of Contents](#table-of-contents)
    - [About this project](#about-this-project)
    - [Compatibility](#compatibility)
    - [Installation](#installation)
        - [Dependencies](#dependencies)
    - [Usage](#usage)
        - [A Simple Example](#a-simple-example)
    - [Using Configuration for Data Grid in Laravel](#using-configuration-for-data-grid-in-laravel)
        - [1. Define Unique Session Key](#1-define-unique-session-key)
        - [2. Retrieve Selected Columns](#2-retrieve-selected-columns)
        - [3. Set Default Columns if Session Data is Not Set](#3-set-default-columns-if-session-data-is-not-set)
        - [4. Get All Available Columns](#4-get-all-available-columns)
        - [5. Render Data Grid](#5-render-data-grid)
        - [6. Pass Data to View](#6-pass-data-to-view)
    - [Configuration for Multiple Tables](#configuration-for-multiple-tables)
        - [1. Define Table Columns](#1-define-table-columns)
        - [2. Specify Unique Column](#2-specify-unique-column)
        - [3. Set Session Key](#3-set-session-key)
        - [4. Enable or Disable Edit Option](#4-enable-or-disable-edit-option)

About this project
------------------

[](#about-this-project)

Custom DataGrid offers a streamlined approach to building robust grids for your Laravel application. Its simplicity in setup and flexibility in customization make it a preferred choice for developers aiming to enhance their data management capabilities.

Compatibility
-------------

[](#compatibility)

Custom DataGrid is fully compatible with Laravel 10, ensuring seamless integration with your existing projects.

Installation
------------

[](#installation)

To begin using Custom DataGrid, follow these simple steps:

1. **Add Dependency**:You can install the package via Composer. Run the following command in your terminal:

    ```
    composer require bytestechnolabs/datagrid
    ```
2. **Service Provider**: Add the Custom DataGrid service provider to your Laravel application's `config/app.php` file:

    ```
    Datagrid\DatagridServiceProvider::class,
    ```
3. **Publish Configuration**: Execute `php artisan vendor:publish --provider="Datagrid\DatagridServiceProvider"` to publish the configuration files.
4. **Autoload**: Refresh the Composer autoload files by running `composer dump-autoload`.
5. **Include Assets**: Include the necessary JavaScript and CSS dependencies in your HTML to enable Custom DataGrid functionality.
6. **Storage link with public** : `php artisan storage:link`

### Dependencies

[](#dependencies)

Make sure to have the following dependencies installed and configured:

- Bootstrap 5
- jQuery

Usage
-----

[](#usage)

### A Simple Example

[](#a-simple-example)

Let's walk through a basic example of implementing Custom DataGrid in your Laravel application.

```
use Datagrid\Facades\DataGridFacade;
use Illuminate\Support\Facades\Session;

public function index()
{
    // Define the unique session key
    $sessionKey = config('datagrid.User_SessionKey');
    // Retrieve the selected columns from the session
    $columns = Session::get($sessionKey);
    // Use default columns if session data is not set
    if ($columns === null) {
        $columns = config('datagrid.users_columns');
        Session::put($sessionKey, $columns);
    }

    // Get all available columns
    $columnsAll = config('datagrid.users_columns');

    // Render the data grid
    $dataGrid = DataGridFacade::model(User::class)
        ->columns($columns)
        ->searchColumns($columns)
        ->columnsAll($columnsAll)
        ->paginate(10);

    return view('your blade file', ['dataGrid' => $dataGrid]);
}
```

Ensure to replace `User::class` with your model in the `DataGridFacade::model()` call.

---

Using Configuration for Data Grid in Laravel
--------------------------------------------

[](#using-configuration-for-data-grid-in-laravel)

To utilize the configuration for the data grid in Laravel, follow the steps outlined below:

### 1. Define Unique Session Key

[](#1-define-unique-session-key)

In your controller method (`index()` in this case), retrieve the unique session key from the configuration file. This key is used to manage sessions related to the specific table.

```
// Define the unique session key
$sessionKey = config('datagrid.User_SessionKey');
```

### 2. Retrieve Selected Columns

[](#2-retrieve-selected-columns)

Retrieve the selected columns from the session using the unique session key obtained in the previous step.

```
// Retrieve the selected columns from the session
$columns = Session::get($sessionKey);
```

### 3. Set Default Columns if Session Data is Not Set

[](#3-set-default-columns-if-session-data-is-not-set)

If the session data for selected columns is not set, use the default columns specified in the configuration file and store them in the session.

```
// Use default columns if session data is not set
if ($columns === null) {
    $columns = config('datagrid.users_columns');
    Session::put($sessionKey, $columns);
}
```

### 4. Get All Available Columns

[](#4-get-all-available-columns)

Retrieve all available columns from the configuration file.

```
// Get all available columns
$columnsAll = config('datagrid.users_columns');
```

### 5. Render Data Grid

[](#5-render-data-grid)

Render the data grid using the Laravel Data Grid package, specifying the selected columns, search columns, and all available columns. Optionally, paginate the results.

```
// Render the data grid
$dataGrid = DataGridFacade::model(User::class)
    ->columns($columns)
    ->searchColumns($columns)
    ->columnsAll($columnsAll)
    ->paginate(10);
```

### 6. Pass Data to View

[](#6-pass-data-to-view)

Pass the data grid to the view for rendering.

```
return view('test', ['dataGrid' => $dataGrid]);
```

By following these steps, you can effectively utilize the configuration for the data grid in your Laravel application.

---

Configuration for Multiple Tables
---------------------------------

[](#configuration-for-multiple-tables)

To configure multiple tables and specify their unique columns and session keys, follow these steps:

### 1. Define Table Columns

[](#1-define-table-columns)

In the `config/datagrid.php` file, specify the columns for each table under the `users_columns` array. Each table should have its own array containing the column names.

Example:

```
'users_columns' => [
    'id',
    'name',
    'email',
    'email_verified_at',
],
```

### 2. Specify Unique Column

[](#2-specify-unique-column)

Define the unique column for each table using the format `ModelName_unique_column`. This configuration is used to validate uniqueness when updating records.

Example:

```
'User_unique_column' => 'email',
```

### 3. Set Session Key

[](#3-set-session-key)

Assign a unique session key for each table using the format `ModelName_SessionKey`. This key is used to manage sessions related to the specific table.

Example:

```
'User_SessionKey' => 'user_columns',
```

### 4. Enable or Disable Edit Option

[](#4-enable-or-disable-edit-option)

Specify whether the table has an edit option available. Set to `true` if the table allows editing, otherwise set to `false`.

Example:

```
'User_has_edit_option' => false,
```

Repeat these steps for each table you want to configure. Ensure that the configuration is accurate and consistent across all tables.

---

Blade File Example
------------------

[](#blade-file-example)

To include the package's view in your Laravel application, follow these steps:

1. Create a new blade file (e.g., `datagrid.blade.php`) in your `resources/views` directory.
2. Add the following code to the blade file:

```
DOCTYPE html>

    Document
    @include('datagrid::layouts.style')

    {!! $dataGrid->render() !!}

```

3. Make sure to include all the necessary styles and render the data grid using the `render()` method provided by the package.
4. You can then use this blade file in your application to display the data grid provided by the package.

The result will be like this: [![datagrid](https://private-user-images.githubusercontent.com/166477168/323221019-d1785338-feeb-4313-8b7a-6cc596a94cd9.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU0MzM5MzMsIm5iZiI6MTc3NTQzMzYzMywicGF0aCI6Ii8xNjY0NzcxNjgvMzIzMjIxMDE5LWQxNzg1MzM4LWZlZWItNDMxMy04YjdhLTZjYzU5NmE5NGNkOS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNDA2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDQwNlQwMDAwMzNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT01ZTZlNDIyNmM2NzkyMWUwMTBjYTEwYmQyOTlhOTU2MmExMTZhYzFlZWQ3YzhjODAyZTZjYTI0YzA3MjljNjViJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.dnnFY4z_oTrVDpbi_HeP8YfVVSj0HZe3VRefS_XrIFk)](https://private-user-images.githubusercontent.com/166477168/323221019-d1785338-feeb-4313-8b7a-6cc596a94cd9.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU0MzM5MzMsIm5iZiI6MTc3NTQzMzYzMywicGF0aCI6Ii8xNjY0NzcxNjgvMzIzMjIxMDE5LWQxNzg1MzM4LWZlZWItNDMxMy04YjdhLTZjYzU5NmE5NGNkOS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNDA2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDQwNlQwMDAwMzNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT01ZTZlNDIyNmM2NzkyMWUwMTBjYTEwYmQyOTlhOTU2MmExMTZhYzFlZWQ3YzhjODAyZTZjYTI0YzA3MjljNjViJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.dnnFY4z_oTrVDpbi_HeP8YfVVSj0HZe3VRefS_XrIFk)

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 73.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

748d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7344554a164b013569f3bee47018263a151e61ee0e074919847662097dd1c2fa?d=identicon)[bhavik.shah](/maintainers/bhavik.shah)

---

Top Contributors

[![urvish-bytes](https://avatars.githubusercontent.com/u/52781453?v=4)](https://github.com/urvish-bytes "urvish-bytes (11 commits)")[![chandan-bytestechnolab](https://avatars.githubusercontent.com/u/166477168?v=4)](https://github.com/chandan-bytestechnolab "chandan-bytestechnolab (4 commits)")

### Embed Badge

![Health badge](/badges/bytestechnolabs-datagrid/health.svg)

```
[![Health](https://phpackages.com/badges/bytestechnolabs-datagrid/health.svg)](https://phpackages.com/packages/bytestechnolabs-datagrid)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
