hello everyone in the premise that I’m a noob, I put in a _form file of a model a grid with filters and practically every filter I try to apply instead of doing the requery on the grid gives me in the view of the basic model.
I explain better in the view _form of customers I put a grid that calls a table of movements, in this grid then I have filters of combobox ,type date and description, practically as I try to apply a filter then I go directly in the view of the customer
below the grid code
Data provider
<?php
Yii::warning("datamov");
$searchMovs = new XMovimentiAllSearch();
Yii::warning($datamov);
$count = Yii::$app->db->createCommand('
SELECT COUNT(ID_card) FROM [x_Movimenti_all] where Id_card=:IDTessera
', [':IDTessera' => $card->ID])->queryScalar();
$provider = new SqlDataProvider([
'sql' => 'select * from [x_Movimenti_all] where Id_card=:IDTessera',
'params' => [':IDTessera' => $card->ID],
'totalCount' => $count,
'pagination' => [
'pageSize' => 15,
],
'sort' => [
'attributes' => [
'Data'
],
],
]);
$movcp = $provider;
?>
GRID
<?php Pjax::begin(['id' => 'Movimenti2']) ?>
<?php //Print_r($dataProvider_all);?>
<?php echo GridView::widget([
'dataProvider' => $movcp,
'filterModel' => $searchMovs,
'columns' => [
[
'attribute' => 'Data',
'format' => 'text'
],
['attribute' => 'tipo',
'filter' => ['doc' => 'Documento', 'Punti' => 'Punti', 'credito' => 'Credito'],
'format' => 'text'],
['attribute' => 'Mov',
'format' => 'text'],
['attribute' => 'Descrizione',
'filter' => Html::input('string', 'Descrizione'),
'format' => 'text'],
['attribute' => 'Note',
'format' => 'text'],
[
'label' => 'Modifica',
'format' => 'raw',
'value' => function($data) {
switch ($data['tipo']){
case 'doc':
$tmpid=$data['ID'];
Modal::begin([
'header'=>'<h4>Movimenti</h4>',
'id' => 'doc'.$tmpid,
'size'=>'modal-lg', //classe bootstrap
]);
echo "<div id='modalContent'></div>";
Modal::end();
$this->registerJs( "
$('#modaldoc_$tmpid').click(function (){
$('#doc$tmpid').modal('show')
.find('#modalContent')
.load($(this).attr('value'));
});"
);
$url=Url::to(['movimentiarticoli/updateaj','id' => $data['ID']]);
return Html::button('Modifica',['value'=>$url,'class' => 'btn btn-success','id'=>'modaldoc_'.$tmpid]);
case 'Punti':
$tmpid=$data['ID'];
Modal::begin([
'header'=>'<h4>Punti</h4>',
'id' => 'punti'.$tmpid,
'size'=>'modal-lg', //classe bootstrap
]);
echo "<div id='modalContent'></div>";
Modal::end();
$this->registerJs( "
$('#modalpunti_$tmpid').click(function (){
$('#punti$tmpid').modal('show')
.find('#modalContent')
.load($(this).attr('value'));
});" );
$url=Url::to(['movimentipunti/updateaj','id' => $data['ID']]);
return Html::button('Modifica',['value'=>$url,'class' => 'btn btn-success','id'=>'modalpunti_'.$tmpid]);
case 'credito':
$tmpid=$data['ID'];
Modal::begin([
'header'=>'<h4>Credito</h4>',
'id' => 'credito'.$tmpid,
'size'=>'modal-lg', //classe bootstrap
]);
echo "<div id='modalContent'></div>";
Modal::end();
$this->registerJs( "
$('#modalcredito_$tmpid').click(function (){
$('#credito$tmpid').modal('show')
.find('#modalContent')
.load($(this).attr('value'));
});" );
$url=Url::to(['movimenticredito/updateaj','id' => $data['ID']]);
return Html::button('Modifica',['value'=>$url,'class' => 'btn btn-success','id'=>'modalcredito_'.$tmpid]);
// return Html::button('Modifica',['movimenticredito/update','id' => $data['ID'],'class' => 'btn btn-success','id'=>'modalcredito_'.$tmpid ]);
}
}
] ,
[
'label' => 'Cancella',
'format' => 'raw',
'value' => function($data) {
switch ($data['tipo']){
case 'doc':
$tmpid=$data['ID'];
Modal::begin([
'header'=>'<h4>Movimenti Cancellazione</h4>',
'id' => 'deldoc'.$tmpid,
'size'=>'modal-lg', //classe bootstrap
]);
echo "<div id='modalContent'></div>";
Modal::end();
$this->registerJs( "
$('#delmodaldoc_$tmpid').click(function (){
$('#deldoc$tmpid').modal('show')
.find('#modalContent')
.load($(this).attr('value'));
});"
);
$url=Url::to(['movimentiarticoli/viewaj','id' => $data['ID']]);
return Html::button('Cancella',['value'=>$url,'class' => 'btn btn-success','id'=>'delmodaldoc_'.$tmpid]);
case 'Punti':
$tmpid=$data['ID'];
Modal::begin([
'header'=>'<h4>Punti Cancellazione</h4>',
'id' => 'delpunti'.$tmpid,
'size'=>'modal-lg', //classe bootstrap
]);
echo "<div id='modalContent'></div>";
Modal::end();
$this->registerJs( "
$('#delmodalpunti_$tmpid').click(function (){
$('#delpunti$tmpid').modal('show')
.find('#modalContent')
.load($(this).attr('value'));
});" );
$url=Url::to(['movimentipunti/viewaj','id' => $data['ID']]);
return Html::button('cancella',['value'=>$url,'class' => 'btn btn-success','id'=>'delmodalpunti_'.$tmpid]);
case 'credito':
$tmpid=$data['ID'];
Modal::begin([
'header'=>'<h4>Credito Cancellazione</h4>',
'id' => 'delcredito'.$tmpid,
'size'=>'modal-lg', //classe bootstrap
]);
echo "<div id='modalContent'></div>";
Modal::end();
$this->registerJs( "
$('#delmodalcredito_$tmpid').click(function (){
$('#delcredito$tmpid').modal('show')
.find('#modalContent')
.load($(this).attr('value'));
});" );
$url=Url::to(['movimenticredito/viewaj','id' => $data['ID']]);
return Html::button('Cancella',['value'=>$url,'class' => 'btn btn-success','id'=>'delmodalcredito_'.$tmpid]);
}
}
],
]
]);
?>
<?php Pjax::end() ?>
practically how I try to filter goes on
http://localhost:8080/index.php?r=clienti%2Fview&id=BFB9DD84-26AE-4677-84AE-A590A9D1901C
any idea why?
TKS A LOT!