jeudi 26 mai 2016

How I can process a checkbox column from Yii2 gridview?

my problem is as follow: I need insert rows into a table from a set of checkboxes in a gridview widget view.

My _add.php code is:

$itemsQuery = Inventory::find();
$itemsQuery->andFilterWhere(['inv_status' => 1, 'inv_condition' => 2]);
$dataProvider = new ActiveDataProvider([
                                       'query' => $itemsQuery,
                                       ]);
echo GridView::widget([
    'id' => 'griditems',
    'dataProvider' => $dataProvider,
    'columns' => [
        ['attribute' => 'inv_group', 'value' => 'invGroup.inv_group'],
        ['attribute' => 'inv_class', 'value' => 'invClass.inv_class'],
        'brand',
        'model',
        'description',
        ['class' => 'yii\grid\CheckboxColumn'],
    ],
]);

I've tried using javascrip

$('element').one('click',function() {
var keys = $('#griditems').yiiGridView('getSelectedRows');
$.post({
   url: 'picked-items/processselected', // your controller action
   dataType: 'json',
   data: {keylist: keys},
   success: function(data) {
      if (data.status === 'success') {
          alert('Total price is ' + data.total);
      }
   },
});

});

However, I can't get results...

I've tried multiples possible solutions with no results, I've read documentations, blogs, forums and I can't do it

I need information about how I can process data into my controller from a set of checkboxes in a gridview table.

Thanks!!




Aucun commentaire:

Enregistrer un commentaire