Skip to content

Commit

Permalink
Added some datagrid features for master branch
Browse files Browse the repository at this point in the history
  • Loading branch information
amit-webkul committed Sep 17, 2024
1 parent 1d47843 commit e02c422
Showing 1 changed file with 134 additions and 0 deletions.
134 changes: 134 additions & 0 deletions docs/master/packages/datagrid.md
Original file line number Diff line number Diff line change
Expand Up @@ -450,3 +450,137 @@ Once you've completed this step, all the data within the DataGrid becomes access
By customizing the DataGrid directly in the Blade file, you won't affect your default DataGrid. This means you can display the same DataGrid with various appearances and customize it by writing simple Vue.js code and using Tailwind CSS (since we use it in Bagisto).
:::

## Available Column Types

Bagisto’s DataGrid supports various column types that allow you to store, display, and manage diverse kinds of data. This also includes a searchability feature, allowing users to filter data by specific criteria. Below is a breakdown of key column types: decimal, integer, string, boolean, date, datetime, and aggregate types.

### Integer Column Type

The integer column type is designed for whole numbers without any fractional or decimal parts. This column type is ideal for counting or identification data. Used for IDs, quantities, and numeric fields that don’t require decimal places.


```php
$this->addColumn([
'index' => 'id',
'label' => trans('blog::app.admin.datagrid.index.id'),
'type' => 'integer',
'searchable' => true,
'filterable' => true,
'sortable' => true,
]);
```

### Decimal Column Type

The decimal column type stores numbers with high precision, allowing fractional parts. It’s ideal for financial or measurement data where exact precision is necessary. Used for columns like product prices, weights, or tax rates that require decimal values.

```php
$this->addColumn([
'index' => 'price',
'label' => trans('blog::app.admin.datagrid.index.price'),
'type' => 'decimal',
'searchable' => true,
'filterable' => true,
'sortable' => true,
]);
```

::: tip
Bagisto’s Decimal and Integer column types support a variety of filtering operations to help users refine their searches effectively. Here’s an overview of the available filtering options and their input formats:

### Supported Input Formats:

#### Decimal Columns:
Exact match: "10.5"
Greater than: ">10.5"
Less than: "<20.75"
Greater than or equal to: ">=15.0"
Less than or equal to: "<25.5"
Range: "10.5-20.75"

#### Integer Columns:
Exact match: "10"
Greater than: ">10"
Less than: "<20"
Greater than or equal to: ">=15"
Less than or equal to: "<25"
Range: "10-20"

Use these formats to apply precise filters to your Decimal and Integer columns and get the data you need more efficiently!

:::

### String Column Type

The string column type stores text or alphanumeric data. It’s widely used for columns that contain names, descriptions, or any textual information. Typically used for product names, customer names, categories, and descriptions.

```php
$this->addColumn([
'index' => 'name',
'label' => trans('blog::app.admin.datagrid.index.name'),
'type' => 'string',
'searchable' => true,
'filterable' => true,
'sortable' => true,
]);
```

### Boolean Column Type

The boolean column type stores binary values such as true or false. It’s useful for indicating the state of a specific condition. Used for status flags like “active/inactive,” “available/unavailable,” or "enabled/disabled."

```php
$this->addColumn([
'index' => 'status',
'label' => trans('blog::app.admin.datagrid.index.status'),
'type' => 'boolean',
'searchable' => true,
'filterable' => true,
'sortable' => true,
]);
```

### Date Column Type

The date column type stores dates, but without time information. It is useful when only the calendar date is important, such as in daily reports or event dates. Often used for birth dates, order dates, or specific event dates.

```php
$this->addColumn([
'index' => 'created_at',
'label' => trans('blog::app.admin.datagrid.index.date'),
'type' => 'date',
'searchable' => true,
'filterable' => 'date_range',
'sortable' => true,
]);
```

### DateTime Column Type

The datetime column type stores both date and time information. This is important when precise timestamps are needed. Used for tracking exact times for events like order creation, login timestamps, or last updated times.

```php
$this->addColumn([
'index' => 'updated_at',
'label' => trans('blog::app.admin.datagrid.index.date'),
'type' => 'datetime',
'searchable' => true,
'filterable' => 'datetime_range',
'sortable' => true,
]);
```

### Aggregate Type Column

The aggregate column type is used for displaying summarized or calculated data, such as totals, averages, or counts derived from other data in the DataGrid. Used to display metrics like total sales, average order value, or product count in categories.

```php
$this->addColumn([
'index' => 'total',
'label' => trans('blog::app.admin.datagrid.index.total'),
'type' => 'aggregate',
'searchable' => true,
'filterable' => true,
'sortable' => true,
]);
```

0 comments on commit e02c422

Please sign in to comment.