Skip to content

DataGrid

DataGrid は Doggy のデータテーブルコンポーネントです。DataGrid エンティティ設定 + DataGridService のサーバーサイド駆動により、ページネーション、ソート、フィルタ、エクスポートなどの高度な機能をサポートします。

概要

DataGrid システムは以下の要素で構成されます(src/Component/Database/):

Component/Database/
├── Bridge/
│   ├── DataSetInterface.php   # 数据集接口
│   ├── DataSource.php         # 数据源抽象
│   ├── DoctrineDataSet.php    # Doctrine 数据集实现
│   ├── FilterCondition.php    # 筛选条件
│   └── FilterGroup.php        # 筛选条件组
└── View/
    └── DataGrid.php           # DataGrid 视图组件

設定

DataGrid は App\Entity\Platform\DataGrid エンティティに設定を永続化し、DataGridService がサーバーサイドのサポートを提供します:

php
use App\Service\Platform\DataGridService;

class DataGridController
{
    public function index(DataGridService $service): Response
    {
        $dataGrid = $service->findDataGridByEntityClass(Department::class);
        $config = $dataGrid->getDefaultConfigData();

        return $this->render('admin/index.html.twig', [
            'gridConfig' => $config,
        ]);
    }
}

フィルタ

DataGrid は FilterConditionFilterGroup でフィルタ条件を構築し、AI 自然言語クエリ Agent と深く統合されています:

  • テキストフィルタ(あいまい/完全一致)
  • 数値範囲フィルタ
  • 日付範囲フィルタ
  • ドロップダウン選択フィルタ
  • 関連エンティティフィルタ(dot notation 対応)

データソース

DataSetInterface でデータソースを抽象化し、現在以下をサポート:

  • DoctrineDataSet: Doctrine QueryBuilder ベース
  • DataSource: データソース基底クラス
  • カスタムデータセットの実装をサポート

フロントエンドコンポーネント

フロントエンドは sunui_datagrid Twig マクロでレンダリングします:

twig
{% include 'components/datagrid.html.twig' with {
    columns: columns,
    data: paginator,
    config: gridConfig
} %}

機能

  • サーバーサイドのページネーションとソート
  • 複数列フィルタ(AND/OR 組み合わせ)
  • データエクスポート
  • AI Agent の自然言語クエリとの統合
  • 設定のデータベースへの永続化

MIT ライセンスでオープンソース | Copyright © 2026 Doggy