[gridview] -- ActionColumn重写
来源:互联网 发布:文化部对网络直播 编辑:程序博客网 时间:2024/04/30 00:19
ActionColumn源码地址: http://blog.csdn.net/lmjy102/article/details/55210410
lulucms中gridView中动作ActionColumn重写
源码如下:
<?phpnamespace source\core\grid;use Yii;use yii\base\Component;use yii\base\ErrorHandler;use yii\helpers\ArrayHelper;use yii\helpers\Html;use yii\base\Model;use yii\web\JsExpression;use yii\helpers\Url;use source\libs\Resource;/** * ActiveField represents a form input field within an [[ActiveForm]]. * * @author Qiang Xue <qiang.xue@gmail.com> * @since 2.0 */class ActionColumn extends \yii\grid\ActionColumn{ public $header = '操作'; //public $footer = 'footerLook'; public $queryParams = []; public $width = '30px'; public $template='{update} {delete}'; public function init() { parent::init(); if (! isset($this->headerOptions['width'])) { $this->headerOptions['width'] = $this->width; } $this->contentOptions=['class'=>'da-icon-column','style'=>'width:'.$this->width.';']; } protected function initDefaultButtons() { if (! isset($this->buttons['view'])) { $this->buttons['view'] = function ($url, $model, $key, $index, $gridView) { //这个getAdminUrl路径=>statics/admin/dandelion return Html::a('<img src="'.Resource::getAdminUrl().'/images/icons/color/magnifier.png">', $url, [ 'title' => Yii::t('yii', 'View'), 'data-pjax' => '0' ]); }; } if (! isset($this->buttons['update'])) { $this->buttons['update'] = function ($url, $model, $key, $index, $gridView) { return Html::a('<img src="'.Resource::getAdminUrl().'/images/icons/color/pencil.png">', $url, [ 'title' => Yii::t('yii', 'Update'), 'data-pjax' => '0' ]); }; } if (! isset($this->buttons['delete'])) { $this->buttons['delete'] = function ($url, $model, $key, $index, $gridView) { return Html::a('<img src="'.Resource::getAdminUrl().'/images/icons/color/cross.png">', $url, [ 'title' => Yii::t('yii', 'Delete'), 'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'), 'data-method' => 'post', 'data-pjax' => '0' ]); }; } } public function createUrl($action, $model, $key, $index) { if ($this->urlCreator instanceof Closure) { return call_user_func($this->urlCreator, $action, $model, $key, $index,$this); } else { $params = \Yii::$app->request->queryParams; if(is_array($key)) { $params=array_merge($params,$key); } else { $params['id']=(string) $key; } if (isset($this->queryParams[$action])) { $params = array_merge($params, $this->queryParams[$action]); } $params[0] = $this->controller ? $this->controller . '/' . $action : $action; return Url::toRoute($params); } } /** * @inheritdoc */ protected function renderDataCellContent($model, $key, $index) { if ($this->content !== null) { return call_user_func($this->content, $model, $key, $index, $this); } return preg_replace_callback('/\\{([\w\-\/]+)\\}/', function ($matches) use($model, $key, $index) { $name = $matches[1]; if (isset($this->buttons[$name])) { $url = $this->createUrl($name, $model, $key, $index); return call_user_func($this->buttons[$name], $url, $model, $key, $index, $this); } else { return ''; } }, $this->template); }}
0 0
- [gridview] -- ActionColumn重写
- [gridview] -- ActionColumn源码
- yii2自定义GridView和ActionColumn
- 使gridview的actioncolumn的图标不再换行
- 重写GridView
- gridView重写
- 重写WebControl-GridView
- [gridView] -- index页面重写
- 自定义控件之重写GridView
- 重写GRIDVIEW 控件 asp.net
- 自定义控件之重写GridView
- actioncolumn vs MVC
- Android重写系列(3)——GridView重写
- 重写getChildDrawingOrder,让gridview倒序绘制item
- GridView 重写画图,实现底下…
- C#中GridView中的分页算法重写
- GridView重写、一次展示所有item
- ExtJS4 actioncolumn动态显示图标
- postman+json+springmvc测试批量添加
- orcad DRC检查,元件C2都没连接,为什麼不报错
- 【TerryHe 博客园】Spring Boot 应用示例
- Thread的start与run
- Android中使用BroadcastReceiver打开和关闭WIFI
- [gridview] -- ActionColumn重写
- lombok
- C++ qt 安装
- 一致性哈希算法(consistent hashing)
- C# ajax 大文件上传
- C语言文件操作详解
- 51cto 学院的培训职业路线图
- sql的aggregate
- 简单聊聊8583