Quantcast
Channel: Krajee Yii2 Extensions – Krajee Web Tips
Viewing all 129 articles
Browse latest View live

Typeahead results are not shown properly in DetailView inside modal. Bug?

$
0
0

Hi Kartik,
I’m using your great DetailView extension and inside I use some of your widgets like Select2 and DateControl. Everything is working nicely, but unfortunately the Typeahead widget is causing me some trouble: the results are shown behind other columns in the DetailView. I already tried to raise the z-index of .tt-menu, but without any success..
My PHP code:

[
'rowOptions' => ['class' => 'kv-view-hidden warning', 'style' => 'border-bottom: 5px double #dedede'],
'columns' => [
[
'attribute' => 'stops',
'value' => $planning->stops,
'label' => 'Zoek stop',
'type' => DetailView::INPUT_TYPEAHEAD,
'widgetOptions' => [
'pluginOptions' => ['highlight' => true],
'dataset' => [
[
'datumTokenizer' => "Bloodhound.tokenizers.obj.whitespace('value')",
'display' => 'value',
'prefetch' => Url::to(['planning/stops']),
'remote' => [
'url' => Url::to(['planning/stops']) . '?q=%QUERY',
'wildcard' => '%QUERY'
]
]
]
],
],
],
]

Hope you can offer me some help.. Thanks in advance!

The post Typeahead results are not shown properly in DetailView inside modal. Bug? appeared first on Krajee Web Tips.


Using Sortable Input with touch

$
0
0

Hi! Do you know if it’s at all possible to implement touch events for Sortable Input? Currently, I can’t use this plugin because of the project being required to work on an iPad. Any tips?

The post Using Sortable Input with touch appeared first on Krajee Web Tips.

Incorrect dropdown content if in json source used 0 as content index

$
0
0

First of all – Kartik – your extensions are great, thanks for them.
My problem is simple.
I need something like this from my dependent-dropdown:

{
"output":[
{"id":"0","name":"---empty---"},
{"id":"1","name":"Mobile Phones"},
{"id":"2","name":"Tablets"},
{"id":"3","name":"Computers & Accessories"},
{"id":"4","name":"Cameras"},
{"id":"5","name":"Televisons"}
],
"selected":""
}

 
But all time I got broken dropdown with some kind of “optgroup” version of content.
Does anybody know whats wrong with me?

The post Incorrect dropdown content if in json source used 0 as content index appeared first on Krajee Web Tips.

DatePicker in FormGrid loaded through $.get doesn't work

$
0
0

When loading a form-template (FormGrid) through renderAjax and feeding that to the page via $.get, I get the error “VM50800:4 Uncaught TypeError: Cannot set property ‘dates’ of undefined”. I read somewhere to ‘reload the assets’. How do I go about that and would that solve this problem?

The post DatePicker in FormGrid loaded through $.get doesn't work appeared first on Krajee Web Tips.

Yii2 widgets into a Grid View Expanded row

changing-the-name-attribute

Select2 question: Check email input and change color

$
0
0

Hi all,
Thanks about good tool to develop web app.
I want to use Select2 widget with tagging but I want to check input (email valid) and change color(valid: green, no valid red) and show alert below (option).
I can get val or text but can not get object to addClass.
Please help me if it is possible.
Thanks.

The post Select2 question: Check email input and change color appeared first on Krajee Web Tips.

disable caching of ajax loaded contents in expanded row component?


findModel Callable is not firing in EditableColumnAction

$
0
0

Recently ran into your web tip (http://webtips.krajee.com/rapidly-setup-gridview-editable-cells-with-editable-column-action/) to simplify the editable cells setup.  I followed the example and it works fine.  However, I need to modify the model access, so I coded the findModel parameter like so: public function actions(){ return ArrayHelper::merge(parent::actions(), [ \’editalloc\’ => [ \’class\’ => EditableColumnAction::className(), \’modelClass\’ => Allocation::className(), \’findModel\’ => function ($id, $action) { $model = AnotherAlloc::findOne($id); // some special handling return $model; }, ], ]);} However, it does not appear that the findModel callable is ever fired.  I am missing something< Mahalo, Joe

The post findModel Callable is not firing in EditableColumnAction appeared first on Krajee Web Tips.

Export bad request

$
0
0

Hi,
Previously my export was working perfectly, but now When i try to export data of any format (pdf, json, excel etc) in the gridview i get
for pdf i get a blank pdf
for json and excel the messege is the same, i get :

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>408 Request Timeout</title>
</head><body>
<h1>Request Timeout</h1>
<p>Server timeout waiting for the HTTP request from the client.</p>
</body></html>


i run composer update a few times in the last few weeks so im not in aposition to
know which update broke this.

I have tried also create a new yii2-basic project and tried this feature as well, its still doesn't work,
so it not a problem with my project.

i have looked at your ExportController/actionDownload and the request is getting to it,
with all the data.
and still i have not been able to locate why this issue is arising.

The post Export bad request appeared first on Krajee Web Tips.

EditableColumn does not work when page is second page and pjax is true

Trying to get property of non-object while using kartik-v for image uploading in Yii2

$
0
0

I’m using kartik-v for an image uploading in a form.
There are two problems.

  • I’ve set the maxFiles on 3 in Model, and in the form the multiple is true but after I browsed one; for the next browsing it’ll over write on the previous one and I can’t have them both.
  • I click on upload or the create button I get Trying to get property of non-object in controller

Controller

public function actionCreate()
    {
        Yii::$app->params['uploadPath'] = Yii::$app->basePath . '/uploads/';
        $model = new Ads();
        $provinces = ArrayHelper::map(Province::find()->all(), 'name', 'name'); 
        if ($model->load(Yii::$app->request->post())){

            $image = UploadedFile::getInstances($model, 'image');
            $model->filename = $image->name;
            $ext = end((explode(".", $image->name)));
            $avatar = Yii::$app->security->generateRandomString().".{$ext}";
            $path = Yii::$app->params['uploadPath'].$avatar;
            if ($model->save()) {

                $image->saveAs($path);
                $model->image_adr = $path;
                return $this->redirect(['view', 'id' => $model->id]);
            }else{
                echo "error on saving the model";
            }

        }
        return $this->render('create', [
            'model' => $model,
            'provinces'=>$provinces,
            ]);
    }

model rules

public function rules()
    {
        return [
            [['type', 'explanation', 'cost', 'province_name', 'address'], 'required'],
            [['type', 'explanation', 'image_adr', 'address'], 'string'],
            [['cost'], 'integer'],
            [['province_name'], 'string', 'max' => 20],
            [['province_name'], 'exist', 'skipOnError' => true, 'targetClass' => Province::className(), 'targetAttribute' => ['province_name' => 'name']],
            [['image'],'safe'],
            [['image'], 'file', 'extensions'=>'jpg, gif, png', 'maxFiles'=>3,],
        ];


and finally the view

<?= $form->field($model, 'image[]')->widget(FileInput::classname(), [
    'options'=>['accept'=>'image/*', 'multiple'=>true],
    'pluginOptions'=>['allowedFileExtensions'=>['jpg','gif','png'], 'overwriteInitial'=>false,]
            ]); ?>



 

 

The post Trying to get property of non-object while using kartik-v for image uploading in Yii2 appeared first on Krajee Web Tips.

DateRangePicker in DetailView. Shows current date instead of earlier saved dates.

$
0
0

Hi Kartik,
I’m trying to use your DateRangePicker in your DetailView Widget. It works fine and I’m able to save the selected dates, but when I’m trying to edit the date range, it shows only the current date. My code and a screenshot of the problem are below.

    [
'columns' => [
[
'attribute' => 'datum',
'value' => $planning->datum .' tot '.$planning->datum_tot,
'label' => 'Van',
'type' => DetailView::INPUT_WIDGET,
'widgetOptions' => [
'class' => DateRangePicker::classname(),
'useWithAddon' => true,
'hideInput' => true,
'startAttribute' => 'datum',
'endAttribute' => 'datum_tot',

'pluginOptions'=> [
'locale'=> ['separator' => ' tot '],
],
],
'labelColOptions' => ['style' => 'width:20%; text-align: right;', 'class' => 'datum_tot'],
'valueColOptions' => ['style' => 'width:80%;', 'class' => 'datum_tot']
],
],
],




The post DateRangePicker in DetailView. Shows current date instead of earlier saved dates. appeared first on Krajee Web Tips.

Can't upload multiple images in the form

$
0
0

this what I’ve done in the form but when I want to brows for the second image it just gets overwrite on the previous one

<?= $form->field($model, 'image')->widget(FileInput::classname(), [
            'options'=>['accept'=>'image/*', 'multiple'=>true, ],
            'pluginOptions'=>[
            'allowedFileExtensions'=>['jpg','gif','png'],
            'overwriteInitial'=>false,
            ]
        ]);
    ?>

The post Can't upload multiple images in the form appeared first on Krajee Web Tips.

Multiple Editable Widgets in a view

$
0
0

Hello Kartik,
I have the same issue. I have a view for orders where I show the lines of the order. I want to make editable the field “unidades” in each order line.

But when I use the widget the values shown in the modal are from the first widget and the data posted to the controller too.
For example, an order with five items. I try to edit the item #4 units and…
1.- The popup opens with the units of item #1
2.- When I update the units the item updated is #1 instead of #4.
The code that invokes the widgets is:

Editable::begin([
'model' => $linea,
'attribute' => 'unidades',
'type' => 'primary',
'size'=> 'lg',
'formOptions' => ['action' => ['/pafcAlbaranLinea/editable']],
]);
echo Html::hiddenInput('linea-id', $linea->id);
Editable::end();

Thanks!

The post Multiple Editable Widgets in a view appeared first on Krajee Web Tips.


Select2 > Add "selected" attribute to "select option" form elements for serialization to POST variables

$
0
0

Hi Kartik, thanks for your awesome work and contributions.
I had a question about the Select2 widget —
It is my understanding that a typical “select” dropdown works as follows according to HTML standard — when an option is selected from a dropdown list, a “selected” tag is added to the select option element (like this: http://www.w3schools.com/tags/att_option_selected.asp)
However using the Select2 component, I noticed the option “name” is added as the “title” attribute with “name” as value — the “select option” element (or multiple elements in the case of a mulitple select) is not updated with the “selected” tag.
I want to serialize the form to send the form POST data via an Ajax request but the selected value does not get serialized because it is not in a supported form input element with the “selected” tag. Can you tell me if there is a way to add the “selected” tag to “select option” element?
Thanks!

The post Select2 > Add "selected" attribute to "select option" form elements for serialization to POST variables appeared first on Krajee Web Tips.

depdrop-multiple-select-preselect-multiple-items-via-ajax

$
0
0

Hi Kartik, Thanks for the great widget. I have a problem with loading via ajax (when the parent changes) a multiple select depdrop : It is only possible to select one item : echo Json::encode([\’output\’ => $out, \’selected\’=>$selected]); $selected is not any array, but a single item. I have worked around this \’feature\’ by including in the output array a \’selected\’ attribute, which when present and non zero selects the item, e.g. : [  \’out\’=>[  [\’id\’=>\'<prod-id-1>\’, \’name\’=>\'<prod-name1>\’, \’selected\’ => \’1\’],  [\’id\’=>\'<prod_id_2>\’, \’name\’=>\'<prod-name2>\’, \’selected\’ => \’1\’]  ],  \’selected\’=>\’\’  ] and modified the java script (dependant-dropdown.js) accordingly (not a big change). Would it be possible for you to include this solution in future releases ? Thanks   Gordon      

The post depdrop-multiple-select-preselect-multiple-items-via-ajax appeared first on Krajee Web Tips.

Expanded row word wrapping

$
0
0

How can I wrap the contents of my expanded column detail so it shows the whole answer in my faq?  I’ve tried many things, including setting noWrap => false but nothing fixes it.
faq/index.php

 <?php Pjax::begin(); ?> <?= GridView::widget([
'dataProvider' => $dataProvider,
//'filterModel' => $searchModel,
'responsive' => true,
'bootstrap'=> true,
'columns' => [
//['class' => 'yii\grid\SerialColumn'],

//'id',
[
'class'=>'kartik\grid\ExpandRowColumn',
'value'=> function ($model,$key,$index,$column) {
return GridView::ROW_COLLAPSED;
},

'contentOptions' => ['style' => 'max-width:960px; overflow: auto; word-wrap:break-word;'],
//'attribute'=>'faq_answer',
//'enableRowClick'=> true,
//'expandIcon'=> '<span class="glyphicon glyphicon-expland"></span>',
//'collapseIcon'=> '<span class="glyphicon glyphicon-collapse"></span>',
'detail'=> function($model,$key,$index,$column) {
$searchModel = new FaqSearch();
$searchModel->id = $model->id;
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);

return Yii::$app->controller->renderPartial('faq-details',[
'model'=> $searchModel,
'dataProvider'=>$dataProvider,
]);
},
],
'faq_question',
//'faq_answer',
//['class' => 'yii\grid\ActionColumn'],
],
]); ?>
<?php Pjax::end(); ?>

faq/faq-detail.php

<?= GridView::widget([
'dataProvider' => $dataProvider,
//'filterModel' => $searchModel,
'responsive' => true,
'bootstrap'=> true,
'responsiveWrap'=>true,
'columns' => [
[
'class'=>'kartik\grid\DataColumn',
'attribute'=>'faq_answer',
'format'=>'raw',
'noWrap'=>false,
'contentOptions' => ['style' => ['overflow: auto;', 'word-wrap:break-word;']],
],
//'faq_answer',
//['class' => 'yii\grid\ActionColumn'],
],
]);
?>

The post Expanded row word wrapping appeared first on Krajee Web Tips.

Problems with expand row

$
0
0

Hi,

When i click on button to expand a row nothing happens. The data is there, but click not working…
module was set on config/main.php
here is my code
<?=
GridView::widget([
‘id’ => ‘gridpesquisa’,
‘dataProvider’ => $pesquisarealizada,
//’filterModel’ => $searchModel,
‘columns’ => [
[
‘class’ => ‘kartik\grid\SerialColumn’,
‘contentOptions’ => [‘class’ => ‘kartik-sheet-style’],
‘width’ => ’36px’,
‘header’ => ”,
‘headerOptions’ => [‘class’ => ‘kartik-sheet-style’]
],
[
‘class’ => ‘kartik\grid\ExpandRowColumn’,
‘width’ => ’50px’,
‘value’ => function ($model, $key, $index, $column) {
return GridView::ROW_COLLAPSED;
},
‘detail’ => function ($model, $key, $index, $column) {
$searchModel = new RespostasSearch;
$searchModel->control_idcontrol = $model[‘idcontrol’];
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
error_log(print_r($model, true));
return Yii::$app->controller->renderPartial(‘_respostascontrol’, [
‘searchModel’ => $searchModel,
‘dataProvider’ => $dataProvider,
]);
},
‘headerOptions’ => [‘class’ => ‘kartik-sheet-style’],
‘expandOneOnly’ => true
],
//’idcontrol’,
‘data:datetime:Data da pesquisa’,
‘dealer’,
],
‘toolbar’ => [
‘{export}’,
‘{toggleData}’
],
‘pjax’ => true,
‘bordered’ => true,
‘striped’ => true,
‘condensed’ => false,
‘responsive’ => true,
‘hover’ => true,
‘floatHeader’ => true,
//’floatHeaderOptions’ => [‘scrollingTop’ => 50],
//’bootstrap’ => true,
//’showPageSummary’ => true,
‘panel’ => [
‘type’ => GridView::TYPE_PRIMARY
],
]);
?>

 

The post Problems with expand row appeared first on Krajee Web Tips.

Problems with expand row

$
0
0

Hi,

When i click on button to expand a row nothing happens. The data is there, but click not working…
module was set on config/main.php
here is my code

GridView::widget([
‘id’ => ‘gridpesquisa’,
‘dataProvider’ => $pesquisarealizada,
//’filterModel’ => $searchModel,
‘columns’ => [
[
‘class’ => ‘kartik\grid\SerialColumn’,
‘contentOptions’ => [‘class’ => ‘kartik-sheet-style’],
‘width’ => ’36px’,
‘header’ => ”,
‘headerOptions’ => [‘class’ => ‘kartik-sheet-style’]
],
[
‘class’ => ‘kartik\grid\ExpandRowColumn’,
‘width’ => ’50px’,
‘value’ => function ($model, $key, $index, $column) {
return GridView::ROW_COLLAPSED;
},
‘detail’ => function ($model, $key, $index, $column) {
$searchModel = new RespostasSearch;
$searchModel->control_idcontrol = $model[‘idcontrol’];
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
error_log(print_r($model, true));
return Yii::$app->controller->renderPartial(‘_respostascontrol’, [
‘searchModel’ => $searchModel,
‘dataProvider’ => $dataProvider,
]);
},
‘headerOptions’ => [‘class’ => ‘kartik-sheet-style’],
‘expandOneOnly’ => true
],
//’idcontrol’,
‘data:datetime:Data da pesquisa’,
‘dealer’,
],
‘toolbar’ => [
‘{export}’,
‘{toggleData}’
],
‘pjax’ => true,
‘bordered’ => true,
‘striped’ => true,
‘condensed’ => false,
‘responsive’ => true,
‘hover’ => true,
‘floatHeader’ => true,
//’floatHeaderOptions’ => [‘scrollingTop’ => 50],
//’bootstrap’ => true,
//’showPageSummary’ => true,
‘panel’ => [
‘type’ => GridView::TYPE_PRIMARY
],
]);

 

The post Problems with expand row appeared first on Krajee Web Tips.

Viewing all 129 articles
Browse latest View live