martynchuk/yii2-editable-cell 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

martynchuk/yii2-editable-cell

最新稳定版本:v1.1.0

Composer 安装命令:

composer require martynchuk/yii2-editable-cell

包简介

Yii2 GridView Editable Cell - editable cells in GridView

README 文档

README

Yii2 GridView Editable Cell - editable cells in GridView for Yii2.

Installation

Install the extension via Composer:

composer require martynchuk/yii2-editable-cell

or add to composer.json:

{
    "require": {
        "martynchuk/yii2-editable-cell": "*"
    }
}

Usage

Basic Usage

In your GridView use EditableColumn instead of a regular column:

use martynchuk\editablecell\EditableColumn;

echo GridView::widget([
    'dataProvider' => $dataProvider,
    'columns' => [
        'id',
        [
            'class' => EditableColumn::class,
            'attribute' => 'name',
            'editableUrl' => ['site/editable'],
        ],
        'email',
    ],
]);

Configuration

[
    'class' => EditableColumn::class,
    'attribute' => 'status',
    'editableType' => 'select', // text, textarea, select, date, number
    'editableUrl' => ['user/update-status'],
    'editableOptions' => [
        'items' => [
            ['value' => 1, 'label' => 'Active'],
            ['value' => 0, 'label' => 'Inactive'],
        ],
    ],
    'primaryKey' => 'id',
    'pjaxContainer' => '#grid-pjax', // Pjax container selector to reload after save
    'afterSave' => 'onStatusUpdated', // JavaScript callback
    'onError' => 'onUpdateError', // JavaScript callback
]

Edit Types

  • text - text input field (default)
  • textarea - multiline text field
  • select - dropdown list (requires editableOptions['items'])
  • date - date picker field
  • number - number input field

Server-side Handling

Use the built-in helper class for easy processing:

use martynchuk\editablecell\EditableHelper;

public function actionEditable()
{
    return EditableHelper::process(Articles::class);
}

Project Structure

yii2-editable-cell/
├── assets/
│   ├── css/
│   │   └── editable-cell.css
│   └── js/
│       └── editable-cell.js
├── src/
│   ├── Bootstrap.php
│   ├── EditableCellAsset.php
│   ├── EditableColumn.php
│   └── EditableHelper.php
├── tests/
├── composer.json
├── LICENSE
└── README.md

License

MIT License

Author

Yurii Martynchuk yura@martynchuk.com

https://buymeacoffee.com/martynchuk

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-10