From e02c4222b534e446392c0a1658ad6e0c46a5ad43 Mon Sep 17 00:00:00 2001 From: amit kumar laravel Date: Tue, 17 Sep 2024 12:57:37 +0530 Subject: [PATCH] Added some datagrid features for master branch --- docs/master/packages/datagrid.md | 134 +++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) diff --git a/docs/master/packages/datagrid.md b/docs/master/packages/datagrid.md index 827b0b593..e20a20c4f 100644 --- a/docs/master/packages/datagrid.md +++ b/docs/master/packages/datagrid.md @@ -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, +]); +``` \ No newline at end of file