作者:cranky
项目:change-log-behavio
/**
* @inheritdoc
* @return bool|string
* @throws Exception
*/
public function run()
{
$model = $this->model;
if (!$model) {
return false;
}
if (!$model->hasMethod('getLog')) {
throw new Exception("Attach " . ChangeLogBehavior::className() . " behavior to " . $model::className());
}
/**
* @var ChangeLogBehavior $model
*/
$logProvider = $model->getLog();
$view = $this->header;
$view .= GridView::widget(['dataProvider' => $logProvider, 'columns' => ['log_time:datetime', 'prefix', ['attribute' => 'message', 'content' => function ($item) {
$messages = unserialize($item['message']);
if (is_array($messages)) {
$message = "";
foreach ($messages as $attr => $changes) {
$message .= $attr . ": " . $changes . "<br>";
}
return $message;
}
return $messages;
}]]]);
return $view;
}
作者:diginov
项目:yii2-metroni
/**
* Inits widget
*/
public function init()
{
parent::init();
$this->initVisible();
$this->initSortable();
//GridViewAsset::register($this->view);
}
作者:nemm
项目:yii2-attachment
public function run()
{
$confirm = Yii::t('yii', 'Are you sure you want to delete this item?');
$js = <<<JS
\$(".delete-button").click(function(){
var tr = this.closest('tr');
var url = \$(this).data('url');
if (confirm("{$confirm}")) {
\$.ajax({
method: "POST",
url: url,
success: function(data) {
if (data) {
tr.remove();
}
}
});
}
});
JS;
Yii::$app->view->registerJs($js);
return GridView::widget(['dataProvider' => new ArrayDataProvider(['allModels' => $this->model->getFiles()]), 'layout' => '{items}', 'tableOptions' => $this->tableOptions, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['label' => $this->getModule()->t('attachments', 'File name'), 'format' => 'raw', 'value' => function ($model) {
return Html::a("{$model->name}.{$model->type}", $model->getUrl());
}], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{delete}', 'buttons' => ['delete' => function ($url, $model, $key) {
return Html::a('<span class="glyphicon glyphicon-trash"></span>', '#', ['class' => 'delete-button', 'title' => Yii::t('yii', 'Delete'), 'data-url' => Url::to(['/attachments/file/delete', 'id' => $model->id])]);
}]]]]);
}
作者:heartshar
项目:yii-multiparse
public static function CreateGridWithDropDownListHeader($dataProvider, $form, $header_model, $arr_header_values)
{
$columns_config = [['class' => SerialColumn::className()]];
$i = 0;
foreach ($header_model as $key => $value) {
$columns_config[] = ['header' => $form->field($header_model, $key, ['inputOptions' => ['label' => '']])->dropDownList($arr_header_values), 'attribute' => $i];
$i++;
}
$dynamic_grid_view = GridView::widget(['dataProvider' => $dataProvider, 'columns' => $columns_config]);
return $dynamic_grid_view;
}
作者:dld
项目:yii2-rel
/**
* Renders interpreter tabs
* @return string tabs
*/
protected function renderViews()
{
$columns = ArrayHelper::getColumn($this->_relViews, function ($element) {
return sprintf('%s:raw', $element['label']);
});
if ($this->actions) {
array_push($columns, $this->actions);
}
$provider = new \yii\data\ArrayDataProvider(['allModels' => [ArrayHelper::map($this->_relViews, 'label', 'content')]]);
echo \yii\grid\GridView::widget(['dataProvider' => $provider, 'columns' => $columns, 'layout' => '{items}', 'pager' => false]);
}
作者:lukianovv
项目:clove
protected function getTable()
{
$options = ['dataProvider' => $this->dataProvider, 'summary' => '', 'tableOptions' => $this->tableOptions];
if ($this->columns) {
$options['columns'] = $this->columns;
}
$table = $this->getPjaxBegin();
$table .= GridView::widget($options);
$table .= $this->getPjaxEnd();
return $table;
}
作者:richardfan112
项目:yii2-sortable-gridvie
public function run()
{
foreach ($this->columns as $column) {
if (property_exists($column, 'enableSorting')) {
$column->enableSorting = false;
}
}
parent::run();
$options = ['id' => $this->id, 'action' => $this->sortUrl, 'sortingPromptText' => $this->sortingPromptText, 'sortingFailText' => $this->failText, 'csrfTokenName' => \Yii::$app->request->csrfParam, 'csrfToken' => \Yii::$app->request->csrfToken];
$options = Json::encode($options);
$this->view->registerJs("jQuery.SortableGridView({$options});");
}
作者:harish-reglobb
项目:Auctio
public function run(){
if($this->is_pjax){
Pjax::begin($this->pjaxOptions);
}
parent::run();
if($this->isShowForm) {
echo PageSize::widget([
'model' => $this->filterModel,
'attribute' => $this->attribute,
'options' => [
'data-pjax' => '0',
],
]);
}
if($this->is_pjax){
Pjax::end();
}
echo ModelCrud::widget([
'size' => $this->modalSize,
'updateUrl' => ($this->updateUrl)? $this->updateUrl : Url::to(['update']),
'createUrl' => ($this->createUrl)? $this->createUrl : Url::to(['create']),
'updateVerb' => 'post',
'viewUrl' => Url::to(['view']),
'viewVerb' => 'post',
'createVerb' => 'post',
'modelTitle' => $this->modelTitle,
'template' => '{view}{update}{create}',
'modelClass' => $this->dataProvider->query->modelClass
]);
}
作者:fufuda
项目:yii2-bas
public function init()
{
parent::init();
$this->emptyText = Html::t('templete', 'noData');
$this->summary = Html::t('templete', 'summary');
$this->getView()->registerCssFile('/css/listStyle.css');
}
作者:nisnake
项目:yii2-templat
public function renderPager()
{
// /controller/action -> #!controller/action
$str = parent::renderPager();
$str = str_replace('href="/', 'href="#!', $str);
return $str;
}
作者:vladimirgolovano
项目:purrfect-awesome-friends-feed-decorato
public function init()
{
$this->showHeader = false;
$this->showFooter = false;
$this->layout = '{items}';
$this->columns = [['class' => 'yii\\grid\\DataColumn', 'format' => 'raw', 'value' => function ($post) {
foreach ($post->postDates as $postDate) {
if (!isset($first)) {
$first = $postDate->PostDate;
}
$last = $postDate->PostDate;
}
if ($first == $last) {
$value = $first;
} else {
$value = $first . ' — ' . $last;
}
if ($post->PostText) {
$value = $value . '<br />' . $post->PostText;
}
return $value;
}], ['format' => 'raw', 'value' => function ($post) {
return '<span class="js-past_vacation_delete grid_delete_icon" data-post-id="' . $post->PostID . '"><i class="fa fa-trash"></i></span>';
}]];
parent::init();
}
作者:h11No
项目:slu
/**
* @inheritdoc
* @return string the rendering result.
*/
public function renderTableBody()
{
if (!$this->showHeader) {
return parent::renderTableBody();
}
$models = array_values($this->dataProvider->getModels());
$keys = $this->dataProvider->getKeys();
$rows = [];
foreach ($models as $index => $model) {
$key = $keys[$index];
if ($this->beforeRow !== null) {
$row = call_user_func($this->beforeRow, $model, $key, $index, $this);
if (!empty($row)) {
$rows[] = $row;
}
}
$rows[] = $this->renderTableRow($model, $key, $index);
if ($this->afterRow !== null) {
$row = call_user_func($this->afterRow, $model, $key, $index, $this);
if (!empty($row)) {
$rows[] = $row;
}
}
}
if (empty($rows)) {
$colspan = count($this->columns);
return "\n<tr><td colspan=\"{$colspan}\">" . $this->renderEmpty() . "</td></tr>\n</tbody>";
} else {
return "\n" . implode("\n", $rows) . "\n</tbody>";
}
}
作者:hucongyan
项目:lulucms
public function renderTableRow($model, $key, $index)
{
if ($this->filterRow !== null && call_user_func($this->filterRow, $model, $key, $index, $this) === false) {
return '';
}
return parent::renderTableRow($model, $key, $index);
}
作者:vinhh
项目:yii2_basic_startu
public function renderSection($name)
{
if ($name == '{tools}') {
return $this->renderTools();
} else {
return parent::renderSection($name);
}
}
作者:consultn
项目:yii2-custom-gri
/**
* @inheritdoc
*/
public function renderSection($name)
{
if (isset($this->pluginSections[$name])) {
return $this->pluginSections[$name]->run();
} else {
return parent::renderSection($name);
}
}
作者:dawei10
项目:yii2-admin-modul
/**
* @inheritdoc
*/
public function init()
{
if (empty($this->columns)) {
$this->columns = $this->columns();
}
$this->columns = array_merge($this->columns, $this->actions());
parent::init();
}
作者:andreosof
项目:andreocm
public function run()
{
parent::run();
echo '</div>';
if (!$this->options['ajax']) {
$this->registerClientScripts();
DataTablesAsset::register($this->getView());
}
}
作者:hackvija
项目:yii-q
/**
* @inheritdoc
*/
public function renderSection($name)
{
switch ($name) {
case '{button}':
return $this->button;
default:
return parent::renderSection($name);
}
}
作者:yeesof
项目:yii2-yee-cor
public function renderSection($name)
{
switch ($name) {
case '{bulkActions}':
return $this->renderBulkActions();
default:
return parent::renderSection($name);
}
}
作者:mole-or
项目:yii2-admi
/**
* @inheritdoc
*/
public function renderSection($name)
{
switch ($name) {
case "{toolbar}":
return $this->renderToolbar();
default:
return parent::renderSection($name);
}
}