When I try to export data in excel using "kartik\editable\Editable::widget" and "ExportMenu::widget" then "Edit" and "Close" sign symbols are also exported in my excel.
How to remove that "Edit" and "Close" Sign symbol while exporting Excel?
return kartik\editable\Editable::widget([
'header'=>false,
'name' => 'status',
'size'=>'sm',
'type'=>'primary',
'placement'=>'right',
'containerOptions'=>['class' => 'kv-sticky-column'],
'contentOptions'=>['class' => 'kv-sticky-column'],
'inputType'=>kartik\editable\Editable::INPUT_TEXT,
'value'=>$location->getSummerValue($location['id']),
'editableValueOptions'=>['asPopover' => false],
'formOptions'=>[
'method' => 'post',
'id' => 'gv1_summer_'.$i.'_form_name',
'action' => ['/forward-price-curve/save-summer?location_id='.$location['id']]
],
'options' => [
'id' => 'gv1_summer_'.$i.'_form_name',
'pluginOptions'=>[
'autoclose'=>true,
'asPopover' => false,
]
],
'submitButton' => [
'class' => 'btn btn-sm btn-primary',
'icon' => '<i class="glyphicon glyphicon-floppy-save"></i>',
],
]);
Related
<?= GridView::widget([
'id' => 'CompanyGrid',
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'floatHeader'=>true,
'floatOverflowContainer'=>true,
'floatHeaderOptions'=>['top'=>'0'],
'pjax'=>true,
'pjaxSettings' => [
'options' => [
'enablePushState' => false,
'enableReplaceState' => true,
]
],
'hover'=>true,
'toolbar' => [
'{export}',
'{toggleData}'
],
'panel' => [
'heading'=>'<h3 class="panel-title"><i class="glyphicon glyphicon-globe"></i> Companies</h3>',
'type'=>'secondary',
'before'=>Html::button('Create Company', ['value'=>Url::to('index.php?r=Company/company/create'), 'title' => 'Create Company', 'class' => 'btn btn-success', 'id' => 'modalButton']),
'after'=>false,
],
'columns' => [
['class' => 'kartik\grid\SerialColumn'],
'CompanyID',
'CompanyName',
['class' => 'kartik\grid\ActionColumn',
'template' => '{view} {update} {delete}',
'buttons' => [
'view' => function($url, $model){
return Html::a('<span class="fa fa-eye"></span>', ['view', 'id' => $model->CompanyID], [
'class' => 'activity-view-link',
'data-pjax'=>'w0',
'title' => Yii::t('yii', 'View Company: '.$model->CompanyID),
'data-toggle' => 'modal',
'data-target' => '#modal',
]);
},
'update' => function($url, $model){
return Html::a('<span class="fa fa-edit"></span>', ['update', 'id' => $model->CompanyID], [
'class' => 'activity-view-link',
'title' => Yii::t('yii', 'Edit Company: '.$model->CompanyID),
'data-toggle' => 'modal',
'data-target' => '#modal',
]);
},
'delete' => function($url, $model){
return Html::a('<span class="fa fa-trash"></span>', ['delete', 'id' => $model->CompanyID], [
'class' => '',
'data' => [
'confirm' => 'Are you absolutely sure? This action is not reversible',
'method' => 'post',
],
]);
}
],
],
],
]); ?>
In Controller
public function actionView($id)
{
$model = Company::findOne($id);
return $this->renderAjax('view', [
'model' => $model,
]);
}
I am new in yii2-advance-apps and i am trying to solve this problem. Already worked on this problem and cannot find any solution for this.
The problem is when I click on the gridview actions buttons, it works. However, after PJax, the button just don't work anymore.
However, if i reload the page, the button works again.
How to solve this problem. Thank you in advance.
'data-pjax' => 0, in action buttons options and not 'w0'
I already search and try every forum and example.
I am using the Kartik\DetailViwew in Yii2 and I can´t manage to put a single custom button in the buttons1 option.
The code I am working on:
echo DetailView::widget([
'model' => $model,
'attributes' => $attributes,
'mode'=>Yii::$app->request->get('edit')=='t' ? DetailView::MODE_EDIT : DetailView::MODE_VIEW,
'panel'=>[
'heading'=>$this->title,
'type'=>DetailView::TYPE_INFO,
],
'buttons1' => '{update}',
'bordered' => 'true',
'striped' => $striped,
'condensed' => $condensed,
'responsive' => $responsive,
'hover' => $hover,
'hAlign'=>$hAlign,
'vAlign'=>$vAlign,
'fadeDelay'=>$fadeDelay,
'deleteOptions'=>[ // your ajax delete parameters
'params' => ['id' => $model->p_id, 'custom_param' => true],
'url'=>['delete', 'id' => $model->p_id],
]
]);
In the
'buttons1' => '{update}',
According to the example http://demos.krajee.com/detail-view, there is a way to customize.
But there is no example. And the documentation not explain how to do this.
Can anyone help?
After research and some tryings, I did it by this way, you have to enable the edit mode (to show buttons), and modify the defatul template ({buttons}{title}), as this template is replaced if the template exists in vender grideview constants, just inject your code to add any button u want. Is not the rigth solution, but is a workaround that works well
<?php
$button1 = Html::a('<i class="glyphicon glyphicon-trash"></i>', Url::to(['delete', 'id' => $model->id]), [
'title' => 'Eliminar',
'class' => 'pull-right detail-button',
'data' => [
'confirm' => '¿Realmente deseas eliminar este elemento?',
'method' => 'post',
]
]);
$button2 = Html::a('<i class="glyphicon glyphicon-pencil"></i>', Url::to(['actualizar', 'id' => $model->id]), [
'title' => 'Actualizar',
'class' => 'pull-right detail-button',
]);
?>
<?=
DetailView::widget([
'model' => $model,
'hover' => true,
'hideAlerts' => true,
'enableEditMode' => true,
'mode' => DetailView::MODE_VIEW,
'hAlign' => 'left',
'panel' => [
'heading' => ' ',
'type' => DetailView::TYPE_DEFAULT,
'headingOptions' => [
'template' => "$button1 $button2 {title}"
]
],
'attributes' => [
'id',
'identificacion',
'nombre',
],
])
?>
Try it like this:
'buttons1' => Html::a('<i class="glyphicon glyphicon-trash"></i>', Url::to(['delete', 'id' => $model->id]), [
'title' => 'Eliminar',
'class' => 'pull-right detail-button',
'data' => [
'confirm' => '¿Realmente deseas eliminar este elemento?',
'method' => 'post',
]
]),
If you have more than one button, try it like this:
$button1 = Html::a('<i class="glyphicon glyphicon-trash"></i>', Url::to(['delete', 'id' => $model->id]), [
'title' => 'Eliminar',
'class' => 'pull-right detail-button',
'data' => [
'confirm' => '¿Realmente deseas eliminar este elemento?',
'method' => 'post',
]
]);
$button2 = Html::a('<i class="glyphicon glyphicon-pencil"></i>', Url::to(['actualizar', 'id' => $model->id]), [
'title' => 'Actualizar',
'class' => 'pull-right detail-button',
]);
'buttons1' => "{$button1} {$button2}",
I have a basic crud based gii. I use modal bootstrap to view the form.
I have code like this :
if ($request->isGet) {
return [
'title' => "Cancel Incoming : $container",
'content' => $this->renderAjax('_form_cancel_incoming', [
'model' => $model,
'min_urut' => $min_urut,
'max_urut' => $max_urut,
'bundles' => $bundles,
'tanggal_real_masuk' => $tanggal_real_masuk
]),
'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) .
Html::submitButton('Cancel', [
'data' =>[
'confirm' => "Apakah Anda Yakin Cancel ?"
],
'class' => 'btn btn-danger',
'title' => 'Cancel',
])
];
} else if ($model->load($request->post())) {
// Can I catch the data-confirm here ?
// If yes, operating the models
return [
'forceReload' => '#crud-datatable-pjax',
'title' => "Your Information",
'content' => "<h3 class='text-success'>Cancel Berhasil</h3>",
'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"])
];
}
My problem is, data-confirm is show, but the operation in post still working, not wating the data-confirm.
Please advise.
I use yii2-grid made by awesome kartik.
My question is, in 'kartik]grid\actionColumn' have default action which is :
view, update, and delete.
I need to add another action, like 'print', 'email', etc.
How can I make do this.
[
'class' => 'kartik\grid\ActionColumn',
'width' => '100px',
'dropdown' => false,
'vAlign' => 'top',
'hiddenFromExport' => true,
'urlCreator' => function ($action, $model, $key, $index) {
return Url::to([$action, 'id' => $key]);
},
'viewOptions' => ['role' => 'modal-remote', 'class' => 'btn btn-xs ', 'title' => 'View', 'data-toggle' => 'tooltip'],
'updateOptions' => ['role' => 'modal-remote', 'class' => 'btn btn-xs btn-primary', 'title' => 'Update', 'data-toggle' => 'tooltip'],
'deleteOptions' => ['role' => 'modal-remote', 'class' => 'btn btn-xs btn-danger', 'title' => 'Delete',
'data-confirm' => false, 'data-method' => false, // for overide yii data api
'data-request-method' => 'post','data-toggle' => 'tooltip','data-confirm-title' => 'Are you sure?','data-confirm-message' => 'Are you sure want to delete this item'],
],
Please advise.
You should make use of the template and buttons options of the ActionColumn:
[
'class' => 'kartik\grid\ActionColumn',
'template' => '{view} {update} {delete} {myaction}', // <-- your custom action's name
'buttons' => [
'myaction' => function($url, $model, $key) {
return Html::a('My action icon', [''my action url];
}
]
...
]
Yii2 delete confirm dialog is not working via menu widget item.
[
'label' => '<i class="fa fa-trash-o alis"></i> Sil',
'url' => ['site/delete', 'id' => $model->id],
'linkOptions' => [
'data-confirm' => 'Are you sure you want to delete this item?',
'data-method' => 'post',
],
'visible' => 'visible'
],
And I see this error:
Method Not Allowed (#405)
Method Not Allowed. This url can only handle the following request methods: POST.
How can I use delete confirm dialog. Then I try this but not working...
[
'label' => '<i class="fa fa-trash-o alis"></i> delete',
'url' => ['site/delete','id' => $model->id],
[
'data' =>[
'data-confirm' => 'Are you sure you want to delete this item?',
'data-method' => 'post',
],
],
'visible' => 'visible'
],
I fixed problem via template options such as following code block:
['label' => '<i class="fa fa-trash-o alis"></i> delete',
'url' => ['site/delete','id' => $model->id],
'template' => '{label}',
'visible' => 'visible'
],
in view file
['label' => '<i class="fa fa-trash-o alis"></i> delete',
'url' => ['site/delete','id' => $model->id],
'template' => '{label}',
'visible' => 'visible'
],
and also in AppAsset file we must active depends array like this:
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
];
You send and GET. But in the controller by default for delete - only POST
send POST or edit rules in contoller, like this:
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'], //delete this string to may GET
],
],
];
}
I think the cause of the error is the HTTP method when you click link difference with method you config for the action in function behaviors() of controller. So you need defined the method for the link (sorry my English is not good). I tryed and it worked:
Html::a('', $url,
[
'data' => [
'method' => 'post',
// use it if you want to confirm the action
'confirm' => 'Are you sure?',
],
'class' => 'glyphicon glyphicon-trash btn btn-default btn-xs custom_button'
]
);