博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
detailview Kartik-v 美好界面的操作
阅读量:6609 次
发布时间:2019-06-24

本文共 5838 字,大约阅读时间需要 19 分钟。

hot3.png

参考网页:

一、下面是摘抄

// DetailView Attributes Configuration$attributes = [    [        'group'=>true,        'label'=>'SECTION 1: Identification Information',        'rowOptions'=>['class'=>'info']    ],    [        'columns' => [            [                'attribute'=>'id',                 'label'=>'Book #',                'displayOnly'=>true,                'valueColOptions'=>['style'=>'width:30%']            ],            [                'attribute'=>'book_code',                 'format'=>'raw',                 'value'=>''.$model->book_code.'',                'valueColOptions'=>['style'=>'width:30%'],                 'displayOnly'=>true            ],        ],    ],    [        'columns' => [            [                'attribute'=>'book_name',                'valueColOptions'=>['style'=>'width:30%'],            ],            [                'attribute'=>'color',                 'format'=>'raw',                 'value'=>"   " . $model->color . '',                'type'=>DetailView::INPUT_COLOR,                'valueColOptions'=>['style'=>'width:30%'],             ],        ],    ],    [        'group'=>true,        'label'=>'SECTION 2: Price / Valuation Amounts',        'rowOptions'=>['class'=>'info'],        //'groupOptions'=>['class'=>'text-center']    ],    [        'attribute'=>'buy_amount',        'label'=>'Buy Amount ($)',        'format'=>['decimal', 2],        'inputContainer' => ['class'=>'col-sm-6'],    ],    [        'attribute'=>'sale_amount',        'label'=>'Sale Amount ($)',        'format'=>['decimal', 2],        'inputContainer' => ['class'=>'col-sm-6'],    ],    [        'label'=>'Difference ($)',        'value'=>$model->buy_amount - $model->sale_amount,        'format'=>['decimal', 2],        'inputContainer' => ['class'=>'col-sm-6'],        // hide this in edit mode by adding `kv-edit-hidden` CSS class        'rowOptions'=>['class'=>'warning kv-edit-hidden', 'style'=>'border-top: 5px double #dedede'],    ],    [        'group'=>true,        'label'=>'SECTION 3: Book Details',        'rowOptions'=>['class'=>'info'],        //'groupOptions'=>['class'=>'text-center']    ],    [        'columns' => [            [                'attribute'=>'publish_date',                 'format'=>'date',                'type'=>DetailView::INPUT_DATE,                'widgetOptions' => [                    'pluginOptions'=>['format'=>'yyyy-mm-dd']                ],                'valueColOptions'=>['style'=>'width:30%']            ],            [                'attribute'=>'status',                 'label'=>'Available?',                'format'=>'raw',                'value'=>$model->status ? 'Yes' : 'No',                'type'=>DetailView::INPUT_SWITCH,                'widgetOptions' => [                    'pluginOptions' => [                        'onText' => 'Yes',                        'offText' => 'No',                    ]                ],                'valueColOptions'=>['style'=>'width:30%']            ],        ]    ],    [        'columns' => [            [                'attribute'=>'author_id',                'format'=>'raw',                'value'=>Html::a('John Steinbeck', '#', ['class'=>'kv-author-link']),                'type'=>DetailView::INPUT_SELECT2,                 'widgetOptions'=>[                    'data'=>ArrayHelper::map(Author::find()->orderBy('name')->asArray()->all(), 'id', 'name'),                    'options' => ['placeholder' => 'Select ...'],                    'pluginOptions' => ['allowClear'=>true, 'width'=>'100%'],                ],                'valueColOptions'=>['style'=>'width:30%']            ],            [                'attribute'=>'rememberMe',                 'label'=>'Remember?',                'format'=>'raw',                'type'=>DetailView::INPUT_SWITCH,                'widgetOptions' => [                    'pluginOptions' => [                        'onText' => 'Yes',                        'offText' => 'No',                    ]                ],                'value'=>$model->rememberMe ? 'Yes' : 'No',                'valueColOptions'=>['style'=>'width:30%']            ],        ]    ],    [        'attribute'=>'synopsis',        'format'=>'raw',        'value'=>'' . $model->synopsis . '',        'type'=>DetailView::INPUT_TEXTAREA,         'options'=>['rows'=>4]    ]];// View file rendering the widgetecho DetailView::widget([    'model' => $model,    'attributes' => $attributes,    'mode' => 'view',    'bordered' => $bordered,    'striped' => $striped,    'condensed' => $condensed,    'responsive' => $responsive,    'hover' => $hover,    'hAlign'=>$hAlign,    'vAlign'=>$vAlign,    'fadeDelay'=>$fadeDelay,    'deleteOptions'=>[ // your ajax delete parameters        'params' => ['id' => 1000, 'kvdelete'=>true],    ],    'container' => ['id'=>'kv-demo'],    'formOptions' => ['action' => Url::current(['#' => 'kv-demo'])] // your action to delete]);// Controller actionpublic function actionDetailViewDemo() {    $model = new Demo;    $post = Yii::$app->request->post();       // process ajax delete    if (Yii::$app->request->isAjax && isset($post['kvdelete'])) {        echo Json::encode([            'success' => true,            'messages' => [                'kv-detail-info' => 'The book # 1000 was successfully deleted. ' .                     Html::a('  Click here',                         ['/site/detail-view-demo'], ['class' => 'btn btn-sm btn-info']) . ' to proceed.'            ]        ]);        return;    }    // return messages on update of record    if ($model->load($post) && $model->save()) {        Yii::$app->session->setFlash('kv-detail-success', 'Success Message');        Yii::$app->session->setFlash('kv-detail-warning', 'Warning Message');    }    return $this->render('detail-view', ['model'=>$model]);}

转载于:https://my.oschina.net/bubifengyun/blog/865869

你可能感兴趣的文章
关于字符串输入的问题
查看>>
NSD基础交换-子网划分
查看>>
rsync的配置部署
查看>>
Java的新项目学成在线笔记-day11(二)
查看>>
思科 DHCP服务器配置及DHCP中继
查看>>
以太坊DAO之时间锁定Multisig
查看>>
这样的APP你还不满意吗?不满意算我输
查看>>
百度城市大会绽放蓉城,弘和受邀“智”创未来
查看>>
深入理解QtCreator的插件设计架构
查看>>
JVM源码分析之Object.wait/notify实现
查看>>
网卡调试
查看>>
零基础web前端学习路线
查看>>
静态路由
查看>>
根据供词确定谁是凶手
查看>>
mongrel
查看>>
一元逆变器概述
查看>>
每2秒获取系统的赋值及内存使用率
查看>>
String类知识点整理
查看>>
oracle 11g 客户端下载_oracle11客户端下载
查看>>
Hadoop2.2 伪分布式配置
查看>>